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 8038355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:12:34+00:00 2026-06-05T03:12:34+00:00

I have been fiddeling with javascripts timestamps the whole morning now. I keep getting

  • 0

I have been fiddeling with javascripts timestamps the whole morning now. I keep getting invalid timestamps by running

today = (new Date()).setHours(0,0,0,0) or today = (new Date()).getTime()

These 2 output 1338930000000 and 1338978151748.

I figured this was just a chrome js engine error but reproduced it with Firefox. The expected output of those 2 statements were 1338930000 and 1338977700.

I do, however, have a fix for this. The fix is this:

today = parseInt(((new Date()).setHours(0,0,0,0) * Math.pow(10, -3)).toFixed(0))

or without setHours()

today = parseInt(((new Date()) * Math.pow(10, -3)).toFixed(0))

Is this a common bug? Am I doing something wrong to get these results? The timestamps are in format timestamp * 10^3.

EDIT:

TURNS OUT I WAS EXPECTING THE TIME IN SECONDS (darn you PHP) WHILE JAVASCRIPT OUTPUTS IT IN MILLISECONDS. I am using the phpJS date / time library, and javasctipt timestamp doesn’t seem to be natively compitable with strtotime() and date()

I was trying to work with unix timestamps, those are in seconds.

  • 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-05T03:12:35+00:00Added an answer on June 5, 2026 at 3:12 am

    getTime() returns the number of milliseconds since 1970/01/01, not seconds.

    //milliseconds
    var milliseconds = new Date().getTime();
    
    //seconds
    var seconds = new Date().getTime() / 1000;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been fiddling with this for almost an hour and am getting nowhere.
I have been working on an iPhone App for a couple of weeks now
I've been trying to use Jquery UI, and I keep getting confused by it.
I have been fiddling with a few lines of code for two days now
I have been fiddling around with server side interceptors on CXF. But is seems
I have been fiddling with code to call a function with the name of
I Have been fiddling with this for hours. I can not get my text
Have been trying to encrypt an xml file to a string so that I
Have been working on this question for a couple hours and have come close
Have been looking on some tutorials for drawing canvas using SurfaceView, but the only

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.