Jump to content

mktime and date question


rxbanditboy1112

Recommended Posts

I would like to know if in the following line of code if the line would always give me 4 hours ago. My biggest concern is when it becomes midnight of the next day... Will it still give me 4 hours ago or will it give me the next day then subtract four hours from the hour.

 

$today  = strtotime(mktime(date("G")-4,date("i"),date("s"),date("n"),date("d"),date("Y"));

Link to comment
https://forums.phpfreaks.com/topic/91293-mktime-and-date-question/
Share on other sites

what you do wit the timestamp is up to you, you just need the value of X seconds from epoch that is 4 hours from current time

 

i.e

<?php
echo date("y-m-d", time()-(4*60*60));
?>

Should do it for you

also

<?php
echo date("y-m-d", strtotime("-4 hours",time());
?>

should also work as well

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.