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

  • Home
  • SEARCH
  • 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 3460214
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:12:09+00:00 2026-05-18T10:12:09+00:00

I have a very weird problem with javascript’s getDate function. At the start of

  • 0

I have a very weird problem with javascript’s getDate function. At the start of some function, i’ve created a Date object using:

var day = new Date(date);  

in which date is a unix timestamp.

I dont change the day object, but after a while I try to get the day of the month of this object, but day.getDate() keeps giving me the wrong value.

For example:

alert(day.getTime() + "-" + day.getDate() + "-"+ day.getMonth() +"-" + day.getFullYear() + "-" + day.getHours() + "-" + day.getMinutes() + "-" + day.getSeconds());  

gives me the following result: 1290297600-15-0-1970-23-24-57

and at some other point the result is: 1290384000-15-0-1970-23-26-24

And this is the weird part, if you lookup the unixtimestamp 1290297600 you’ll see that that’s the timestamp for the 21st of november 2010 at 00:00:00 gmt (1290384000 is the next day, same time)
The timestamps are correct, but i cant make sense of the dates it gives me.
This happens to me in any browser.

What am i doing wrong?

  • 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-05-18T10:12:10+00:00Added an answer on May 18, 2026 at 10:12 am

    The issue here is that the Date object in JavaScript doesn’t take the Unix timestamp (seconds since the epoch), it actually takes the milliseconds since the epoch. If you just multiply your date variable by 1000 then you get the correct output.

    Example here

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

Sidebar

Related Questions

So I have a very weird problem. I am writing some code in VB.Net
I am facing this very weird problem, I have created a custom UITableViewCell on
I have a very weird problem: sometimes when I call nHibernate update to an
I have seen some very weird for loops when reading other people's code. I
I have a very strange problem. Under some elusive circumstances I fail to apply
I have a very weird problem in Firefox ( version 3.5.2), and I am
I have a very weird problem.. I really do hope someone has an answer
I have a very weird problem, when storing my session in Memcached. From time
I have a very weird problem with resx based localization. At first, let me
We have very strange problem, one of our applications is continually querying server by

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.