Jump to content

Time + n Hours causing 24 hr clock probems....


nevynev

Recommended Posts

Hi there,

 

I've got the clocks for various cities on a site of mine and just realised that if $london time is e.g. 19:12 then $tokyo time is 27:12 !! Obviously that's wrong but I can't quite figure out how to make it work like a correct 24hr clock...

 

Here's the code:

 

<?php
$london = date("H:i");
$paris = sprintf("%02d", date("H")+1).":". sprintf("%02d", date("i"));	
$milan = sprintf("%02d", ("H")+1).":". sprintf("%02d", date("i"));	
$new_york = sprintf("%02d", date("H")-5).":". sprintf("%02d", date("i"));	
$tokyo = sprintf("%02d", date("H")+.":". sprintf("%02d", date("i"));
?>

 

Thanks for any help!

NevyNev

Link to comment
https://forums.phpfreaks.com/topic/70932-time-n-hours-causing-24-hr-clock-probems/
Share on other sites

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.