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

The Archive Base Latest Questions

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

I can call parse method of Date object directly as follows: alert(Date.parse(March 21, 2012));

  • 0

I can call parse method of Date object directly as follows:

    alert(Date.parse("March 21, 2012"));

However I cannot do this:

    alert(Date.getTime()); // TypeError: Date.getTime is not a function

That is how I get it working:

    alert(new Date().getTime()); // works well

So why can’t I call Date.getTime() directly like Date.parse()?

Underlying Question: I have written a class and I want to use some of its methods directly like Date.parse() above.

  • 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:47:06+00:00Added an answer on June 9, 2026 at 8:47 pm

    As others have pointed out, JavaScript uses prototypes to defined instance methods. You can however defined static methods as shown below. I am not trying to define the whole Date object here, but rather show how its instance and static functions are defined.

    // constructor defined here
    function Date() {
        // constructor logic here
    }
    
    // this is an instance method
    DateHack.prototype.getTime = function() {
        return this.time_stamp;
    }
    
    // this method is static    
    Date.parse = function(value) {
        // do some parsing
        return new Date(args_go_here);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can call partial method from a view object. However, I need to call
request.url returns me this : http://localhost:3000/page?foo=bar . Is there a method I can call
I can call the webservie directly to the browser with the following URL and
From this code I can call bmwCars.CopyToDataTable() as I expected. var bmwCars = from
I have a static method like this public static string DoSomethingToString(string UntrustedString) { //parse
I have a program that progresses as follows. I call a method called getCharacteristics
Is there a Ruby method I can call to get the list of installed
This answer implies I can use getattr on an xmlrpc server proxy. However, in
In Ruby I can call methods with array elements used as positional parameters like
With CreateProcessAsUser I can call an .exe file somewhere on the hard disk: CreateProcessAsUser(IntPtr

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.