hackalive Posted December 30, 2010 Share Posted December 30, 2010 Hi guys I am looking for a loop which will run untill there is a difference of 10 minutes. The timestamp I wish to use is "ISO 8601 date (added in PHP 5)" [ date("c")] If anyone know some code for this it would be much appreicated. I can do the loop its just the comparison between the two timestamps as part of the loop I have no idea where to start on. Cheers, and thanks in advance. Quote Link to comment Share on other sites More sharing options...
trq Posted December 30, 2010 Share Posted December 30, 2010 http://php.net/manual/en/datetime.diff.php Quote Link to comment Share on other sites More sharing options...
hackalive Posted December 31, 2010 Author Share Posted December 31, 2010 @thrope: thanks This is the code date_default_timezone_set("Australia/Perth"); $datetimestamp1 = '2010-12-13T13:22:13+08:00'; $datetimestamp2 = date('c'); $interval = date_diff($datetimestamp1, $datetimestamp2); echo $interval->format('%i'); renders error: Warning: date_diff() expects parameter 1 to be DateTime, string given in J:\mowes_portable\www\update\index.php on line 16 Fatal error: Call to a member function format() on a non-object in J:\mowes_portable\www\update\index.php on line 17 Quote Link to comment Share on other sites More sharing options...
hackalive Posted January 5, 2011 Author Share Posted January 5, 2011 bump Quote Link to comment Share on other sites More sharing options...
johnny86 Posted January 5, 2011 Share Posted January 5, 2011 You need to create DateTime object for that function, here is an example I posted a while a go a little modifed: <?php // Create DateTime object with your timestamp $date = new DateTime("'2010-12-13 13:22:13', new DateTimeZone('Australia/Perth')); // Calculate the difference between your timestamp and "now" $interval = $date->diff(new DateTime()); // Get the data stored in the DateInterval echo $interval->format("Differernce is %d days, %h hours %i minutes and %s seconds."); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.