Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Random Date format

Hi everyone,

As weird as it can appears, when I call the function new Date() sometimes he gives me date in this format: Mon Jun 21 2010 09:07:09 GMT+0200 and sometimes in this one: 2010-06-21 09:07:09 +0200.

So how can I be sure to get one of these format?

— asked June 21st 2010 by Brice Torriani
  • date
  • iphone
0 Comments

2 Answers

  • Accepted Answer

    > t's a shame because I'd like to pass the date in the first format

    So use the Date object's built in "get" methods to get said format

    http://www.devguru.com/technologies/javascript/10585.asp

    — answered June 21st 2010 by Stephen Gilboy
    permalink
    1 Comment
    • It is really helpful that you added link to non existing page

      — commented January 30th 2014 by Martin Gmuca
  • Okay I get it. When you place it into a string it will be the first format. So the code below:

    var now = new Date();
    Ti.API.info(now);
    Ti.API.info(" "+now);
    

    will give:

    [INFO] 2010-06-21 09:50:27 +0200
    [INFO] Mon Jun 21 2010 09:50:27 GMT+0200 (CEST)
    

    It's a shame because I'd like to pass the date in the first format in an HTTP request (also I have to use a string…)

    — answered June 21st 2010 by Brice Torriani
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.