Getting Hour and Minute in PHP Getting Hour and Minute in PHP php php

Getting Hour and Minute in PHP


print date('H:i');$var = date('H:i');

Should do it, for the current time. Use a lower case h for 12 hour clock instead of 24 hour.

More date time formats listed here.


Try this:

$hourMin = date('H:i');

This will be 24-hour time with an hour that is always two digits. For all options, see the PHP docs for date().


print date('H:i');

You have to set the correct timezone in php.ini .

Look for these lines:

[Date]; Defines the default timezone used by the date functions;date.timezone =

It will be something like :

date.timezone ="Europe/Lisbon"

Don't forget to restart your webserver.