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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:45:46+00:00 2026-06-09T23:45:46+00:00

Is there a way to take a date object from a HTML object in

  • 0

Is there a way to take a date object from a HTML object in the format of ####-##-## and convert it to epoch time. For example, the user inputs the value of August 12, 2012 which shows as 2012-08-12 when I print out the .val() of it, and I need to get this in Epoch time.

EDIT

Code to date:

if (hvStartDate == "") {
    hvStartDate = "start"
} 
else {
    console.log($("#hv-start-date").val()); // => 2012-08-20
    hvStartDate = new Date($("#hv-start-date").val()).getTime(); // => NaN
}
if (hvEndDate == "") {
    hvEndDate = "end"
} 
else {
    hvEndDate = new Date($("#hv-end-date").val()).getTime(); // => NaN
}

var myTmp = new Date("2012-08-20");
console.log(myTmp.getTime()); // => NaN
  • 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-09T23:45:48+00:00Added an answer on June 9, 2026 at 11:45 pm

    Javascript’s Date built-in allows you to pass a date string into its constructor, giving you a Date based on that string. From there, calling getTime( ) will give you the epoch time.

    new Date($('.user-value').val()).getTime();  // => epoch time
    new Date('2012-08-12').getTime();  // 1344729600000
    

    Caveat: Beware of locale strings and locale-specific date formatting (for example, the position of days and months switch depending on locale).

    EDIT: Based on your code in the comment below, here’s what you need to do. Notice that you have to instantiate a new Date Object before calling getTime():

    if (hvStartDate == "") {
        hvStartDate = "start"
    } 
    else {
        hvStartDate = new Date($("#hv-start-date").val()).getTime();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to take any number, from say, 1 to 40000 and
Is there a way to take HTML and import it to excel so that
Is there some way I can take text (retrieved from a form), and email
Is there a way to determine the original date/time of a Wordpress blog post?
Is there a way to take a text label and an URL and use
Is there a way to take text like below (if it was already in
Is there a way to take a chunk of XML/XAML and load it as
Is there a way to take a compiled SWF file and figure out how
I could do this using loops, but is there a way to take two
Is there any convenient way to take an array/set of objects and create a

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.