Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if time

Status
Not open for further replies.

ivow

Programmer
Aug 6, 2002
55
CA
I want to create an if statement based on time like this:

<% if time<10 then
response.write variable
end if %>

How would I write 5 pm? Or any other time for that reason? Would I have to convert the time to decimals? Like 10:26 is 10.46667? That doesn't really make sense to me.

I've looked through FAQ and can't seem to find anything about this.

Thanks a lot,

ivo &quot;If it's stupid but works, it isn't stupid.&quot;
 
If its just a case that you want something to happen if someone comes to your site at or after 5pm then...
if Time>=&quot;17:00:00&quot; then response.write &quot;It's now after 5pm&quot; Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
Time depends on the regional settings of the server that executes your asp, here is an example:
<% @ Language =&quot;VBScript&quot; %>
<%
Response.Expires = 0
response.write time() & &quot;<br>&quot;
response.write now() & &quot;<br>&quot;
response.write date() & &quot;<br>&quot;
response.write &quot;24H timeformat: &quot; & formatDateTime(now(),4)
nowUS = cdate(date())
mybirthdayUS = cdate(&quot;11/01/&quot; & year(date()))
if mybirthdayUS > nowUS then
response.write &quot;your birthday is still ahead of you for this year<br>&quot;
else
response.write &quot;your birthday has passed for this year<br>&quot;
end if
%>
 
I removed some notes from the code so let me explain:
nowUS = cdate(date())' this is because the date settings on the server are M/d/yyyy (US style) so 01/02/2002 means second of januari
' if the datesettings were UK style than date() will give me the date d/M/yyyy so 01/02/2002 would mean first of februari
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top