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