Jump to content

0 value


Miss-Ruth

Recommended Posts

I'm curious.... This time difference never ends. it doesn't send 0. Is there a more efficient way in doing this or please could someone tell what's wrong here.

 

<?php
$timezone =  new DateTimeZone('Africa/Gaborone');
$date = new DateTime('now', $timezone);
$start_time=strtotime($date->format('Y-m-d H:i:s'));
$end_time=strtotime("2010-12-14 17:9:0");
echo round(abs($start_time - $end_time));
?>

 

Thanks,

Ruth.

Link to comment
https://forums.phpfreaks.com/topic/221597-0-value/
Share on other sites

Ok. I'm using this to create a countdown timer. Could someone show me how this should be done or how can I get the time difference between $start_time and $end_time stop at 0.

 

<?php
$timezone =  new DateTimeZone('Africa/Gaborone');
$date = new DateTime('now', $timezone);
$start_time=strtotime($date->format('Y-m-d H:i:s'));
$end_time=strtotime("2010-12-14 17:9:0");
echo round(abs($start_time - $end_time));
?>

 

Thanks,

Ruth.

Link to comment
https://forums.phpfreaks.com/topic/221597-0-value/#findComment-1147270
Share on other sites

Maybe this is what you want?

 

<?php
$timezone =  new DateTimeZone('Africa/Gaborone');
$date = new DateTime('now', $timezone);
$start_time=strtotime($date->format('Y-m-d H:i:s'));
$end_time=strtotime("2010-12-14 17:9:0");
if ($start_time>$end_time)
   echo 0;
else
   echo ($end_time - $start_time);
?>

Link to comment
https://forums.phpfreaks.com/topic/221597-0-value/#findComment-1147278
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.