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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:55:44+00:00 2026-05-30T04:55:44+00:00

How I will convert this time 11:34 to javascript timestamps. Any javascript functionality available

  • 0

How I will convert this time 11:34 to javascript timestamps. Any javascript functionality available for that.

I am trying to create a floting graph for that I am using Flot library. In my graph time on x axis and count on y axis. For creating data part I need to convert time to timestamp like that thay specified on API doc.

http://people.iola.dk/olau/flot/API.txt

This is my code

var datasets = {
    "usa": {
        label: "Logged Users",
        data: [[10:55, 4], [11:00, 1], [11:05, 4], [11:10, 2], [11:15, 3], [11:20, 1], [11:25, 5]]
    }
};

if (datasets.length > 0){
    $.plot($("#placeholder"), datasets, {
        yaxis: { min: 0,tickDecimals: 0 },
        xaxis: {  mode: "time",timeformat: "%H:%M" }
    });
}

It will not work because I specified exact time instead of a number. So I need to convert that to timestamps format.
Please help me.

Thanks

  • 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-30T04:55:45+00:00Added an answer on May 30, 2026 at 4:55 am

    Use an instance of the Date object:

    var sTime = '11:34';
    var oDate = new Date();
    oDate.setUTCHours(
        parseInt(sTime.substr(0, 2), 10),
        parseInt(sTime.substr(3, 2), 10),
        0,
        0
    );
    var sTimestamp = oDate.getTime();
    

    Also see this example.

    === UPDATE ===

    When the time is local time instead of UTC, then you can set the time with:

    oDate.setHours(
        parseInt(sTime.substr(0, 2), 10),
        parseInt(sTime.substr(3, 2), 10),
        0,
        0
    );
    

    Also see this example.

    P.s.: the result of getTime() is in milliseconds.

    === UPDATE ===

    To map your current dataset you can use following script (with UTC; if you want local time remove the UTC in the setter):

    var aCountries = [ "usa" ];
    var oDate = new Date();
    oDate.setSeconds(0, 0);
    for (var i = 0; i < aCountries.length; i++) {
        datasets[aCountries[i]].data =
            datasets[aCountries[i]].data.map(function(oElement) {
                oDate.setUTCHours(
                    parseInt(oElement[0].substr(0, 2), 10),
                    parseInt(oElement[0].substr(3, 2), 10)
                );
                return [
                    oDate.getTime()
                    , oElement[1]
                ];
            });
    }
    

    Also see this example.

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

Sidebar

Related Questions

This is my first time using XSLT. I'm trying to create a file that
Does anyone know of any (free) tools that will convert an old Delhi 5
We are starting to create an application using JavaScript and HTML5 which will use
I've seen this: how to get formatted date time like 2009-05-29 21:55:57 using javascript?
Right now I have double numba = 5212.6312 String.Format({0:C}, Convert.ToInt32(numba) ) This will give
I have a script that will convert a text file into a resource file,
Is there a tool available which will convert source code in Perl to source
I have functions in place that will convert the results of sql queries into
Is there a tool that will convert MS Access SQL to T-SQL?
I need a function that will convert a type to a string, for example:

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.