Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:33:02+00:00 2026-06-09T20:33:02+00:00

if dd = 2012-08-20 01:16:00; converting this date to time-stamp (as in the following

  • 0

if dd = "2012-08-20 01:16:00";
converting this date to time-stamp (as in the following code)

var t = new Date(dd).getTime();

http://jsfiddle.net/userdude/DHxwR/

the result t = NaN why ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:33:03+00:00Added an answer on June 9, 2026 at 8:33 pm

    According to ECMA-262 (§15.9.1.15, Date Time String Format, page 169), the only date string format required to be accepted is:

    [+YY]YYYY[-MM[-DD]][THH:mm[:ss[.sss]]]Z
    

    where Z is either Z (for UTC) or an offset consisting of either a + or a - followed by HH:mm. Any other formats that happen to be supported by a particular browser should not be relied upon, as continued support is not guaranteed.

    Therefore, replace the space with a T and append either a Z, or a fixed time zone offset before passing it to the Date constructor. For example, if the date and time are in the UTC+8 zone:

    var dd = "2012-08-20 01:16:00";
    var t = new Date(dd.replace(' ', 'T') + '+08:00').getTime();
    

    This will return the number of milliseconds from January 1, 1970, midnight UTC, to the date you have specified, treated as either universal time (if you appended Z) or a time local to the fixed time zone offset that you specify.

    Please note that this will act differently in that the date is not simply treated as time local to the user’s system time zone as your question’s example does. However, I can’t think of a situation where doing that would be useful, because you’d get different results depending on the user’s configuration — but in reality, the time difference between two dates is always the same no matter where you are.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In oracle converting this date 2012-07-03 11:38:41 to unix_timestamp we get select (to_date('2012-07-03 11:38:41','YYYY-MM-DD
On my website we store all time & date in the following format: Table
I have this problem converting java.sql.Timestamp.toString back to java.sql.Timestamp . Given element = 2012-08-01
Ok I have this exact date: 2012-10-01T13:00:00+0000 I need to split it into two
I wrote this bit of code for converting string to Timestamp: String timeStamp =
This works as fine in my ASP.NET page's SqlDataSource: <asp:SessionParameter Name=FromTimestamp SessionField=fromtime DefaultValue=2/22/2012 />
I'm converting a string Jun 11, 2012 9:30 PM to an NSDate and I
2012-03-21T04:01:09+00:00 DEBUG (7): fopen(/data01/virt32830/domeenid/www.montonfashion.com/htdocs/var/cache/mage--6/mage---internal-metadatas---bee_DB_PDO_MYSQL_DDL_catalog_product_flat_3_3): failed to open stream: Permission denied/data01/virt32830/domeenid/www.montonfashion.com/htdocs/lib/Zend/Cache/Backend/File.php The question is: Why
Edit (2012-04-12): Since this question was asked it is now possible (as of jQuery
I have this string 2012-06-27 16:17:06 and I want to convert it to GMT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.