Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.