homepage Welcome to WebmasterWorld Guest from 54.242.231.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Formatting Time and Date ASP
Formatting the date and time using asp script...
isaaclloyd




msg:943161
 8:51 am on May 10, 2005 (gmt 0)

Here is what I am trying to do:

<%
=time - 2 hours
%>

I need to write the time in this format: 12:30pm but -2 hours so it write 10:30am because my server is 2 hours ahead of MY time zone.

Also...I am trying to write a date like this:

May 10th, 2005.

and then anywhere I want put "Monday" so something like:

Today is <% =MyWeekDay %> and the date is: <% =MyFormattedDate %>

If anyone has any suggestions or cooments I would greatly appreciate it. Thanks

~Isaac~

[edited by: Woz at 8:57 am (utc) on May 10, 2005]
[edit reason] No Sigs please, see TOS#13 [/edit]

 

mrMister




msg:943162
 12:41 pm on May 10, 2005 (gmt 0)

Today is <% =Split(FormatDateTime(MyDate,vbLongDate),", ")(0) %> and the date is: <% =Split(FormatDateTime(MyDate,vbLongDate),", ")(1) %>

mrMister




msg:943163
 1:01 pm on May 10, 2005 (gmt 0)

Oh, sorry. I didn't realise you'd posted two questions.

Here's how you'd do the code in full...

<%
Dim ServerDate,MyDate,DateArray,MyDay,MyDateSection,MyYear
ServerDate = Now()
MyDate = DateAdd("h", -2, ServerDate)
DateArray = Split(FormatDateTime(MyDate,vbLongDate),", ")
MyDay = DateArray(0)
MyDateSection = DateArray(1)
MyYear = DateArray(2)
%>

Today is <%=MyDay%> and the date is: <%=MyDateSection%>, <%=MyYear%>

This will work if your server uses the English Language. I'm not sure about foreign languages.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved