Solved

Format the date

Posted on 2000-02-23
6
432 Views
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?
0
Comment
Question by:Lee5
6 Comments
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
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
 

Accepted Solution

by:
memilavi earned 50 total points
Comment Utility
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
 

Expert Comment

by:Arvindtn
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Lee5
Comment Utility
Format(MyDate, "dddd, mmm d yyyy")
Not valid in vb script
0
 

Author Comment

by:Lee5
Comment Utility
That was a start.  I still needed to do quite a bit of formatting to get the exact format the standard wants.
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now