www.webdeveloper.com
Results 1 to 2 of 2

Thread: Converting IETF-syntax date string to Date

  1. #1
    Join Date
    Apr 2007
    Posts
    1

    Converting IETF-syntax date string to Date

    Hello! I have a quick question. I can't seem to convert a date string which is in the IETF syntax into a Date object. The following code does not work:

    Code:
    var mydatestring = "Tue Apr 17 08:59:17 GMT-0500 2007";
    
    var mydate = new Date(mydatestring );
    mydate returns an error "Invalid Date".

    Does anyone know what the problem is?

  2. #2
    Join Date
    Feb 2006
    Posts
    2,927
    var D="Tue Apr 17 08:59:17 GMT-0500 2007";
    var D = Date.parse(D);
    D=new Date(D);


    D.toUTCString() returns 'Tue, 17 Apr 2007 13:59:17 UTC';

    If you, the server or the visitor is not in Atlantic Canada you may want to convert it to UTC when you make a string out of it.
    Last edited by mrhoo; 04-17-2007 at 09:24 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles