How to display time before or time from a specified javascript or php date

Basically I need to display how much time is up to a certain time or if it has passed, how much time has passed since it was transmitted.

The original line will look like this: 07/20/2011 01:13 am

EDIT: transition from doing conversion in javascript to php:

 //get local time in UTC format echo gmdate("Y/m/d\TH:i:s\Z"); echo '<br />'; //convert time to UTC $the_date = strtotime("07/20/2011 01:13 am"); echo date("Y/m/d\TH:i:s\Z",$the_date); 

Doing the above gives me this to work with:

 //local time 2011/07/20T19:49:39Z //specified time 2011/07/20T01:13:00Z 

How can I take the indicated time and local time and make it look like these examples:

 Started 36 mins ago Will start in 33 mins Will start in 6 hrs 21 mins Will start in 4 days 4 hrs 33 mins 
+6
source share
2 answers

And if you want to do this in Javascript, it is a little painful, but you will get the advantage of a live countdown.

Here's a big breakdown on how to do this.

http://ditio.net/2010/05/02/javascript-date-difference-calculation/

+5
source

See manual . Example # 3 using dated will help you too.

0
source

Source: https://habr.com/ru/post/893138/


All Articles