- Instant help with your Php coding problems

Get current time in PHP

How to get current time in PHP?
// Current time in server timezone
$currentTime = date('H:i:s');

// Current time in selected timezone
$currentTimeNY = date('H:i:s');

To get the current time, simply use the date function with the appropriate format string. To get only hours and minutes use H:i and if you also need the seconds, then use the H:i:s format string.

It is important that the date function is based on the time zone set on the server. If you want to query the current time in another time zone, you must first set the desired time zone with the date_default_timezone_set function.

Supported timezones
Share "How to get current time in PHP?"