I am trying to create a javascript countdown timer;
I have a string that is in the format of YYYY-MM-DD HH:MM:SS .
This could be any time up to 6 months in the future.
What would be the best way to go about getting the time remaining in seconds from now until the future time. This could be implemented in PHP.
Thanks in advance!
In PHP you can use
strtotime, which takes a string representation of a date and returns the unix timestamp.Then use
microtimeto get the current unix timestamp, and find the difference. This will be the number of milliseconds remaining, so divide it by 1000 to get it in seconds.http://php.net/manual/en/function.strtotime.php
http://php.net/manual/en/function.microtime.php
This should work: