Hi, I want to display current time on a web page in this format hh:mm (like 19:07) Only hour and minute. How can I do this?
Yep You got this covered. So if you wanted to display the time on the page then i would be: <?php echo date("H:i", time()); ?> If you wanted to put in into a variable you should be able to do: <?php $currentTime = date("H:i", time()); ?> Then you could just put it in a database or do whatever you wanted with it.
You don''t need to add time() as the second argument, because it is the default parameter. So echo date('H:i'); PHP: will work fine You can find more info about it on http://hu2.php.net/manual/en/function.date.php
Thanks all, I guess I should have visited http://tr.php.net/manual/en/function.date.php before asking. But we all are here to ask and learn, right? I also learned strtotime() function which allows to get the timezone difference into account. Here is the function I'm using now: date('Y.m.d, H:i', strtotime('now + 3 hours')) PHP: