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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:16:50+00:00 2026-05-20T02:16:50+00:00

Why is the following expression invalid? var hello = new Date(2010, 11, 17, 0,

  • 0

Why is the following expression invalid?

var hello = new Date(2010, 11, 17, 0, 0, 0, 0);

For example, hello.UTC() doesn’t work.

  • 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-20T02:16:51+00:00Added an answer on May 20, 2026 at 2:16 am
    var hello = new Date(2010, 11, 17, 0, 0, 0, 0);
    console.log(hello.toUTCString());
    

    and

    var hello2 = Date.UTC(2010, 11, 17, 0, 0, 0, 0);
    console.log(hello2);
    

    These two are actually two different functions that print out different things.

    toUTCString() – Converts a Date object to a string, according to universal time

    where as

    Date.UTC() – returns the number of milliseconds in a date string since midnight of January 1, 1970, according to universal time.

    If you are attempting to calculate the milliseconds in a date string since midnight of 1-1-1970 then you will have to use Date.UTC();. However if you are attempting to get properties, in different forms, of the new Date(2010, 11, 17, 0, 0, 0, 0); then you’ll have to use its own constructor methods (toUTCString() or getUTCMilliseconds() and etc).

    UTC appears to be a member of the Date constructor itself, and not a member of Date instances. So, in order to invoke UTC you have to use Date.UTC(); Date() converts current time to a string, according to universal time and Date.UTC() retrieves and use value that is calculated in milliseconds from 01 January, 1970 00:00:00 Universal Time (UTC). So, they are like a ‘static’ functions.

    Moreover, in JavaScript whenever you use the 'new' keyword to create a new object (instantiate), the this value of the constructor points to the new Object. So, hello can have a date of its own as oppose to Date() or Date.UTC()‘s this would be pointing to a different scope (global i think) which would do its calculation based on 1-1-1970 00:00:00 or return the time which Date function is invoked. The Object hello, on the other hand, would have a base date which was instantiated with new Date(2010, 11, 17, 0, 0, 0, 0) with its set of constructed methods (toUTCString(); and etc). The new Date with this pointing to the new Object using the passed properties as the base “date” value.

    With all these being said, hello.UTC() is accessing a function that is not a member of its constructor and thus doesn’t work. This is part of the OOP in JavaScript. This is all on top of my head and probably a bit fuzzy if you are reading this. Please correct me if i have errors.

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

Sidebar

Related Questions

What does the following expression return in Java? Math.max(Float.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); I saw this question
Does anyone know if the following expression will be possible in the next version(s)
I have a validation control that has the following expression: (?=(.*\\d.*){2,})(?=(.*\\w.*){2,})(?=(.*\\W.*){1,}).{8,} That's a password
I have the following string expression in a PowerShell script: select count(*) cnt from
I have the following regular expression : I figured out most of the part
I have the following regex expression to match html links: <a\s*href=['|](http:\/\/(.*?)\S['|]> it kind of
I don't understand, why does the following regular expression: ^*$ Match the string 127.0.0.1?
The following simple calculator expression grammar (BNF) can be easily parsed with the a
The following returns Type of conditional expression cannot be determined because there is no
I have the following string: cn=abcd,cn=groups,dc=domain,dc=com Can a regular expression be used here to

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.