Lee5
asked on
Format the date
In ASP, using vb script, I want to set a date string to the following format:
Wed, 23 Feb 2000 13:02:45 -0500
How can I do this?
Wed, 23 Feb 2000 13:02:45 -0500
How can I do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can use the Format() provided by VB to do this
Format(MyDate, "dddd, mmm d yyyy") This
Returns "Wednesday, ' Jan 27 1993".
DtFormat & Format(MyDate,, "hh:mm:ss AMPM") This Returns "05:04:23 PM".
now you can use ur logic to format this content in whatever way u want
Format(MyDate, "dddd, mmm d yyyy") This
Returns "Wednesday, ' Jan 27 1993".
DtFormat & Format(MyDate,, "hh:mm:ss AMPM") This Returns "05:04:23 PM".
now you can use ur logic to format this content in whatever way u want
ASKER
Format(MyDate, "dddd, mmm d yyyy")
Not valid in vb script
Not valid in vb script
ASKER
That was a start. I still needed to do quite a bit of formatting to get the exact format the standard wants.
Then why did you accept an answer? And what function is "FomratDateTime"
Do you have any books on VBScript? Returning the date is one of the first and simplest script functions around, if you can't even do this then get a book.
Do you have any books on VBScript? Returning the date is one of the first and simplest script functions around, if you can't even do this then get a book.
There is no function in VBS to convert a date to this format, but you can use the above to convert a date string to your format. You can use Jscript to get GMT;
function TZDemo()
{
var d, tz, s = "The current local time is ";
d = new Date();
tz = d.getTimezoneOffset();
if (tz < 0)
s += tz / 60 + " hours before GMT";
else if (tz == 0)
s += "GMT";
else
s += tz / 60 + " hours after GMT";
return(s);
}