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?
Who is Participating?
memilaviConnect With a Mentor Commented:
You can use the 'FomratDateTime' function of VB.

For example:


Will give you the long format of the date and time as specified in your server 'regional settings' (can be found at the 'control panel').

Usually, the long date format looks like the format you are looking for.

Good Luck!
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";
    s += tz / 60 + " hours after GMT";
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

Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Lee5Author Commented:
Format(MyDate, "dddd, mmm d yyyy")
Not valid in vb script
Lee5Author Commented:
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.
All Courses

From novice to tech pro — start learning today.