Jump to content


Photo

mktime help


  • Please log in to reply
6 replies to this topic

#1 djones

djones
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts
  • LocationWinston-Salem, NC

Posted 10 October 2006 - 01:32 AM

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?

#2 djones

djones
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts
  • LocationWinston-Salem, NC

Posted 10 October 2006 - 12:14 PM

Can someone help please?

#3 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 10 October 2006 - 01:17 PM

If you just need to add 30 minutes to the time, then do this:
<?php
$time = "09:00:00";
echo date('H:i:s',strtotime("+30 minutes")-time()+strtotime($time));
?>


#4 djones

djones
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts
  • LocationWinston-Salem, NC

Posted 10 October 2006 - 01:57 PM

That worked. I would have never figured out the strtotime(). Thanks

#5 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 10 October 2006 - 02:07 PM

shorten it up a bit:
<?php
$time = "09:00:00";
echo date('H:i:s', strtotime("$time +30 minutes"));
?>

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#6 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 10 October 2006 - 02:13 PM

shorten it up a bit:

<?php
$time = "09:00:00";
echo date('H:i:s', strtotime("$time +30 minutes"));
?>


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

#7 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 10 October 2006 - 02:14 PM

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


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

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users