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

For example:

ld_date=FormatDateTime(date(),1)

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!
0
 
mgfranzCommented:
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);
}
0
 
ArvindtnCommented:
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


0
Never miss a deadline with monday.com

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
0
 
Lee5Author Commented:
That was a start.  I still needed to do quite a bit of formatting to get the exact format the standard wants.
0
 
mgfranzCommented:
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.
0
All Courses

From novice to tech pro — start learning today.