faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems : Times/Dates

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 16 people (81%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I show my country's local time on my web site using ASP?

May 31st, 2000 07:13
unknown unknown, Jason K. Monroe


The time function is included in the server side script delimiters..

        <%= Time() %> 

        is the shorthand way of stating 

        <Script RunAT=Server Language=VBScript>
                Response.Write Time()
        </Script>

--------------

- If your server is in the same timezone as your country you can use:

The date function, format it properly and response.write the string on
your page.

- If the server is in a different timezone to your country then:

Take the date() and add the number of hours to get it right.

For example my server is in Kentucky, I add 14 hours to get Japan 
Standard Time

Like so:

<%response.write now()+ 14/24 %>

Alternate:

This might do the trick depending on how your country handles daylight 
savings time.

<%
        Dim NewDate
        NewDate = DateAdd("h", 14, Now)

        Response.Write NewDate
%>



© 1999-2004 Synop Pty Ltd