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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:57:10+00:00 2026-06-09T19:57:10+00:00

I have the following code: var date = new Date(2010,09,09); //09.10.2010 00:00 date.setHours(-1); //sets

  • 0

I have the following code:

var date = new Date(2010,09,09); //09.10.2010 00:00
date.setHours(-1); //sets the date to 08.10.2010 23:00

Calling date.setHours(-1); sets the date to 23:00 at the previous day (at least for Opera and Chrome).

Is this legal?

  • 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-09T19:57:11+00:00Added an answer on June 9, 2026 at 7:57 pm

    Yes, this is effectively what the specification dictates, so it would be an "illegal" implementation if it didn’t.

    The actual computation happens in MakeDate. The date is converted into milliseconds, as is the -1 hours. These are then added. Adding a negative number does subtraction, so you get an earlier date.

    If day is not finite or time is not finite, return NaN.

    Return day × msPerDay + time.

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

Sidebar

Related Questions

I have multiple instances of the following code. var start_time = new Date().getTime(); setTimeout(function
I have the following code to get the current day: var month=new Array(12); month[0]=January;
I have now the following code: var d = new Date(); var curr_hour =
I have the following code: var carsContext = new CarsDataContext(); IQueryable<Car> allCars = carsContext.Cars;
I have the following code: var tlp = new TableLayoutPanel { Location = new
Following on from a previous question, I have the following code: var results =
I have following code in controller: public ActionResult Index(string date) { var topsong =
I have following code var res = from c in model.Data select new object[]
I have the following code: $(function () { var thedate = /Date(1198908717056)/; var thedate2
I have the following code: var resultArticles = from a in articleItems select new

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.