Format the date

Posted on 2000-02-23
Medium Priority
Last Modified: 2012-06-27
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?
Question by:Lee5
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 18

Expert Comment

ID: 2551772
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";

Accepted Solution

memilavi earned 150 total points
ID: 2553248
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!

Expert Comment

ID: 2554652
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


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 2554989
Format(MyDate, "dddd, mmm d yyyy")
Not valid in vb script

Author Comment

ID: 2555001
That was a start.  I still needed to do quite a bit of formatting to get the exact format the standard wants.
LVL 18

Expert Comment

ID: 2555374
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.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question