Jump to content

time().... HELP!!!


robcrozier

Recommended Posts

Hi all, what im trying to do is add or take away one minute from a time which comes from a databes.

 

what im currently doing is calling a 'datetime' field from the database and then using the explode() function to seperate the date and the time.  once i am left with the time, how can i get PHP to treat it like a time and either add or remove one minute? 

 

I think i'm over complicating things at the minute!

 

Any help would be great!

 

Cheers!

Link to comment
https://forums.phpfreaks.com/topic/81399-time-help/
Share on other sites

OK, thanks for the reply Ken but im a bit of a novice when it comes to time functions in PHP.  How would i process it with PHP strtotime() function.  Also, i might mention that i would also like to convert some user input in the form of HH:MM:SS to a valid php time var so that i can compare etc..

 

 

 

cheers!

Link to comment
https://forums.phpfreaks.com/topic/81399-time-help/#findComment-413125
Share on other sites

You can use the strtotime() function to convert the string to an integer containing the number of seconds since 1970-1-1.

 

<?php
$str = '16:10:24';
$tim = strtotime($str);
echo $tim ."<br>";
$tim += 60;
echo date('G:i:s',$tim) . "\n";
?>

 

Ken

 

Link to comment
https://forums.phpfreaks.com/topic/81399-time-help/#findComment-413140
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.