Jump to content

Archived

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

djones

mktime help

Recommended Posts

mktime is confusing for me. Can someone please help me to convert 09:00:00 (HH:MM:SS) add 30 min to the time, 09:30:00, and convert to unix time 093000?

Share this post


Link to post
Share on other sites
If you just need to add 30 minutes to the time, then do this:
[code]<?php
$time = "09:00:00";
echo date('H:i:s',strtotime("+30 minutes")-time()+strtotime($time));
?>[/code]

Share this post


Link to post
Share on other sites
That worked. I would have never figured out the strtotime(). Thanks

Share this post


Link to post
Share on other sites
shorten it up a bit:
[code]
<?php
$time = "09:00:00";
echo date('H:i:s', strtotime("$time +30 minutes"));
?>
[/code]

Share this post


Link to post
Share on other sites
[quote author=obsidian link=topic=111019.msg449839#msg449839 date=1160489241]
shorten it up a bit:
[code]
<?php
$time = "09:00:00";
echo date('H:i:s', strtotime("$time +30 minutes"));
?>
[/code]
[/quote]

Ahh, nice. I was looking in the manual, but I couldn't see if it was possible to give a time and a +30 minutes thing...

Share this post


Link to post
Share on other sites
[quote author=Daniel0 link=topic=111019.msg449844#msg449844 date=1160489597]
Ahh, nice. I was looking in the manual, but I couldn't see if it was possible to give a time and a +30 minutes thing...
[/quote]

yes, i believe you can also do it like this:
[code]
<?php
echo date('H:i:s', strtotime($time, "+30 minutes"));
?>
[/code]

Share this post


Link to post
Share on other sites

×

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.