Solved

Format the date

Posted on 2000-02-23
6
434 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
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";
  else
    s += tz / 60 + " hours after GMT";
  return(s);
}
0
 

Accepted Solution

by:
memilavi earned 50 total points
ID: 2553248
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
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


0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

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

Author Comment

by:Lee5
ID: 2555001
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
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.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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/…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

825 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