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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:21:08+00:00 2026-06-08T00:21:08+00:00

im writing a small calendar based on php and jquery which has the a

  • 0

im writing a small calendar based on php and jquery which has the a function to calculate the time difference and display a popup 15 minutes before.

Can some one tell me how can i calculate the time difference in minutes and popup 15 minutes before.

my time is saved as

18-07-2012 15:13:54
  • 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-08T00:21:10+00:00Added an answer on June 8, 2026 at 12:21 am

    jsBin demo

    var php = '19-07-2012 03:00:00'.split('-');
    var phpDate   = php[1]+'/'+php[0]+'/'+php[2];
    var phpTime   = new Date(phpDate).getTime();
    var currTime  = new Date().getTime();
    var difference= phpTime-currTime; 
    var leftMin   = Math.ceil( difference/(1000*60) );
    
    $('#test').text(leftMin+' MINUTES LEFT!');
    

    Code explanation:

    To get the remaining time I’ve done a millisecond comparison of the php returned time in milliseconds from Jan. 1 1970
    and the current time in ms from Jan 1 1970 – subtracting the two values and getting the milliseconds difference. To calculate that difference in minutes I’ve just done:

     var leftMin   = Math.ceil( difference/(1000*60) );
    

    The trick was to get the right time format and to revert your (php) returned time to that format too.
    The default format looks like: MONTH/DAY/YEAR HOURS:MINUTES:SECONDS

    To convert the php returned time '19-07-2012 03:00:00'to that one, I used:

    var php = '19-07-2012 03:00:00'.split('-');   // split in array fractions
    var phpDate   = php[1]+'/'+php[0]+'/'+php[2]; // reposition array keys and add '/'
    

    which returns: 07/19/2012 03:00:00 and now we can compare it to the current time e.g.:

               07/19/2012 03:45:21
    

    To retrieve the ms from your converted php time we can use:

    var phpTime   = new Date(phpDate).getTime();  // get "ms from our string
    

    and for the current time we just take:

    var currTime  = new Date().getTime();         // get "ms from 1/1/1970
    

    Now having our two milliseconds values we can simply subtract them to get the remaining time:

    var difference= phpTime-currTime;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing small utility app (JBoss Netty based) which should perform some trivial login
I'm writing small VB.Net app which should build reports based on data gathered from
I'm writing a small app to display tasks and upcoming calendar items as a
I am writing small app, using Play Framework 2.0 which uses Ebean as ORM.
Coming from a PHP background, I'm used to writing small functions that return a
I am writing a small jQuery plugin to allow inline editing (for my purposes
I'm writing a small RMI based Chat application. The idea is: the Client registers
I´m writing a small prgramm in which the User is able to send small
I'm writing a small application which updates my AD with info from a DB
I am writing a small module which will have several different aspects to it,

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.