Time Zones

Get DateTime now for a specific time zone try { $TimeZone = new DateTimeZone('America/New_York'); $LocalDateTime = new DateTime(gmdate("Y-m-d\TH:i:s")); //gmdate gives UTC/GMT datetime $LocalDateTime->setTimezone($TimeZone); echo $LocalDateTime->format('Y-m-d\TH:i:s'); } catch (Exception $e) { //Will occur if DateTimeZone string is not valid }      

Read More

Time Difference

Seconds Since DateTime $video_age_seconds = strtotime(date("Y-m-d H:i:s")) – strtotime($video_date_uploaded); Number Of Days Until $start = strtotime(date("Y-m-d H:i:s")); //Now $end = strtotime($result[‘my_end_date’]); if ($start > $end) { $no_of_days = 0; } else { $no_of_days = ceil(abs($end – $start) / 86400); //ceil rounds the amount of days up to the next full day. Use floor if you […]

Read More

Duration

Convert Seconds To Duration Time Format $seconds_input = $video_duration; //The value in seconds (e.g. 1568.782) $hours = (int)(($minutes = (int)($seconds = (int)($milliseconds = (int)($seconds_input * 1000)) / 1000) / 60) / 60); $duration_string = $hours.’:’.($minutes%60).’:’.($seconds%60).((($milliseconds%1000) === 0) ? ” : ‘.’.rtrim($milliseconds%1000, ‘0’));

Read More

Date And Time

Good resources http://www.mysqlformatdate.com/ http://www.devshed.com/c/a/MySQL/Practical-Date-Time-examples-with-PHP-and-MySQL/ Displaying Date And Time Current Date and Time Special characters you can use: http://php.net/manual/en/function.date.php Get hours now From A String Variable (e.g. a MySQL result) From A Date Time Variable (e.g. returned from a MySQL query) Values you can use Date in # days time Compare Date Time Adjusting Date Time Values […]

Read More