Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15413] iOS: Logging date to console shifts time by several hours

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2013-11-11T17:35:27.000+0000
Affected Version/sRelease 3.1.3
Fix Version/s2013 Sprint 24, 2013 Sprint 24 API
ComponentsiOS
Labelsipass1
ReporterMatej
AssigneePedro Enrique
Created2013-10-01T04:45:08.000+0000
Updated2017-03-28T20:20:36.000+0000

Description

Ti.API.log(new Date(1380589200000));
Ti.API.log(new Date(1380589200000).getHours());
*OUTPUT:* 2013-10-01 01:00:00 +0000 // WRONG 3 // RIGHT The right date is: 2013-10-01 03:00:00 +0000, you can test it in browser's console or http://www.ruddwire.com/handy-code/date-to-millisecond-calculators // I have no idea how it is possible ,but now it shows two hours instead three.

Comments

  1. Matej 2013-10-05

    Please can somebody have a look on this issue? Thanks
  2. Matej 2013-10-08

    Note: If I run log that contains some string + Date it return different format of date ,but it is right!
       Ti.API.log(new Date(1380589200000));
       Ti.API.log("-> "+new Date(1380589200000));
       
    *OUTPUT:* [INFO] : 2013-10-01 01:00:00 +0000 [INFO] : -> Tue Oct 01 2013 02:00:00 GMT+0100 (BST)
  3. Pedro Enrique 2013-11-04

    Hi Matej, The result of both logs are identical, the difference is that the first log outputs it in the NSDate string format and the second in the .toString() format of the JS Date object. If you log the JS Date object a native NSDate object is created and the string representation gets logged: "2013-10-01 01:00:00 +0000" If you add a string to the date ("->" + new Date()) it will output the "toString()" version of the JS date. This is because the JS Engine converts it to a string at runtime and the native code reads it as a string, not a date.
  4. Matej 2013-11-05

  5. Pedro Enrique 2013-11-11

    Resolving issue as invalid
  6. Eric Merriman 2017-03-28

    Closing

JSON Source