Jump to content

Date format with +1


Guest seminem
 Share

Recommended Posts

Guest seminem

HELLOHere is what I need (and have spent my last hours trying to figure out)I have

$time = "2006-05-11T21:13:00+01:00";

My local time is 21:13:00 but when I do this

$time = (strtotime("$time"));$nydato = date('j M - H:i', $time);

I get the time 22:13. How can I get it to be 21:13? I know I can do something like this:

$time = (strtotime("$time"));$time = $time - 3600;                 // Minus one hour$nydato = date('j M - H:i', $time);

But tomorrow or any day $time might be like this

$time = "2006-05-11T21:13:00+03:00";

which will ruin the "- 3600" hack.Any suggestions? Please help I am frustrated.Thanks in advance

Link to comment
Share on other sites

A unix timestamp is just a number, you can add and subtract whatever you want from it. Since the number is in seconds (or milliseconds, if you use microtime), you can add a day like this:$timest += (24 * 60 * 60);Or subtract an hour:$timest -= (60 * 60);I do know that there are 86,400,000 milliseconds in a day. I don't think I'll ever forget that.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...