Print Page | Close Window

Formatting time

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7749
Printed Date: 31 March 2026 at 9:41pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Formatting time
Posted By: adnan248999
Subject: Formatting time
Date Posted: 30 November 2003 at 8:17pm

Right I have come across people on neowin.net asking how to do this too so here it is. Adding a specfied number of hours to a time value.

Let's say we wanted to display the time adding 2 hours an 4 minutes we'd do this:

<%

response.write(Time()+2/24+4/1440)

%>

And thats it we add 2 divided by the number of hours in a day then add 4 minutes divided by the number of minutes in a day which is 1440 hope this help anyone who ever wanted ot know how to do this.




Replies:
Posted By: MorningZ
Date Posted: 30 November 2003 at 8:48pm

http://www.devguru.com/Technologies/vbscript/quickref/dateadd.html - DateAdd function will do the trick: DateAdd("N",124,Now())

and if you wanted now + 2hr and 4 mins, you would just add 124 mins



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: adnan248999
Date Posted: 01 December 2003 at 5:13am
Originally posted by MorningZ MorningZ wrote:

http://www.devguru.com/Technologies/vbscript/quickref/dateadd.html - DateAdd function will do the trick: DateAdd("N",124,Now())

and if you wanted now + 2hr and 4 mins, you would just add 124 mins

Cool didn't know about the DateAdd function thanx for that




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net