Link to home
Start Free TrialLog in
Avatar of Lee5
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?
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

Look at the MakeLegalCookieDate() in VBS 2.0.

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);
}
ASKER CERTIFIED SOLUTION
Avatar of memilavi
memilavi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Arvindtn
Arvindtn

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


Avatar of Lee5

ASKER

Format(MyDate, "dddd, mmm d yyyy")
Not valid in vb script
Avatar of Lee5

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.