Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript date object changes
    primarykey
    data
    text
    <p>I have been reading up on dates for days, seemingly going in circles here. I have a string in a DB that looks like this</p> <pre><code>2012,03,13,01,31,38 </code></pre> <p>I want to create a js date object from it so...</p> <pre><code>new Date(2012,03,13,01,31,38); </code></pre> <p>Easy enough, right? But it comes back as</p> <pre><code>2012-04-13 05:31:38 +0000 </code></pre> <p>So the month is off by 1 and the time is off by 4 hours (maybe DST or Timezone related???). I simply want a date that matches the one I provided. Its driving me nuts, dealing with these JS date objects.</p> <p>How can I be sure the date object is the exact same date and time as the string suggests, I have no need for Timezone or DST changes, simply a date that matches a string.</p> <p>More specifics regarding application: My application for this need is for an iphone app I am developing in Titanium (which builds using JS). Basically, part of my app involves logging data and with that log I collect the device's current date and time. I save all of this information to a mySQL database. The field in the database looks like this format: "2012-02-16 00:12:32"</p> <p>Here is where I start to run into problems. I am now offering the ability to edit the log, including the date and time it was logged. In order to use an iPhone "picker", I must convert the string above into a JS date object again. This usually screws things up for me. I essentially need to create a new date object with the date above, with timezone and dst being completely irrelevant, so that when I save back to the DB, its just the string above, modified as per the users request. It needs to not matter whether they are editing in pennsylvania or china, they are editing the same log date.</p> <p>Sorry if this has been confusing. I am having a hard time figuring out this whole date stuff.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload