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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:02:44+00:00 2026-06-08T04:02:44+00:00

Sadly I’m not a jQuery/JavaScript guru and I’m stumped with a problem. In short,

  • 0

Sadly I’m not a jQuery/JavaScript guru and I’m stumped with a problem.

In short, there’s going to be an event where the price of a few fixed items goes down by the minute between two dates.

For example:

2012 07 25 - $1500 -> 2012 08 01 - $1000

And my problem is I don’t even know where to start with making this a real-time countdown. Only the price is needed to appear. Any help, pointers, alternatives would be a great help.

Thanks to the replies I was able to create a solution. Sadly the pure JS version which Esailija supplied didn’t want to work, but based on that I was able to create a php/ajax solution for this. Yes, I know this will put a strain on the server, but the JS version showed a whole new set of numbers not defined in the range, but php with the same formula produced valid results. Below you can find the full php code for this.

<?php

$dateStart = strtotime("16 july 2012 00:00");
$dateEnd = strtotime("18 july 2012 9:30");
$curDate = strtotime("now");

$startPrice = 3628000;
$endPrice = 3499000;

$progress = ($curDate - $dateStart) / ($dateEnd - $dateStart);

$curPrice = $startPrice - ($startPrice-$endPrice) * $progress;

$curPrice = round($curPrice);

if ($dateStart > $curDate) {
   echo $startPrice;
} elseif ($curDate >= $dateEnd) {
   echo $endPrice;
} else {
   echo $curPrice;
}

?>
  • 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-08T04:02:46+00:00Added an answer on June 8, 2026 at 4:02 am

    Get price like this:

    function getPrice() {
        var startDate = Date.UTC(2012,06,25,0,0,0,0),
            endDate = Date.UTC(2012,07,01,0,0,0,0),
            startPrice = 1500,
            endPrice = 1000,
            rightNow = +new Date,
            progress,
            price;
    
        progress = ( rightNow - startDate ) / ( endDate - startDate );
    
        if( progress < 0 ) {
            price = startPrice;
        }
        else if( progress >= 1) {
            price = endPrice;
        }
        else {
            price = startPrice - Math.abs(startPrice-endPrice) * progress;
        }
    }
    

    If right now is less than startDate, price is 1500.
    If right now is more than endDate, price is 1000
    If right now is between, it is calculated

    Demo: http://jsfiddle.net/5v4yh/1/

    Demo uses 2012 07 10 - $1500 -> 2012 07 15 $1000 so it’s in the calculation phase

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

Sidebar

Related Questions

I need to get a notification when ComputedHorizontalScrollBarVisibility changes. Sadly, there is no Event
I can't use JQuery sadly I need to use good old Javascript. I have
JQuery-ui will generate a div with a calendar-div class. Sadly this div is no
I'm working with a Ruby project for school, and have sadly not been able
I have some elements I want to display. But sadly it does not work
stupid problem. I get those from a client connecting to a server. Sadly, the
I have an x11 display with a windowmanager (sadly not a specific one, could
I want to show ... when overflow happens, but sadly in css there is
after I found out (sadly) that there is no easy way to create a
Say you have something like the following (sadly, I'm not allowed to post the

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.