How do I convert 12 hour clock time into 24 hour clock time in PHP?
From the docs for date()
: The H
format character gives the hour in 24h format. Also, you can use G
if you do not want the leading 0
for hours before noon.
Examples (if current time was seven-something-AM)
date('H:i:s')
-> "07:22:13"
date('G:i:s')
-> "7:22:13"
For your specific case:
$timestamp = date("d/m/Y H:i:s", time());
According to the manual the difference is in the capitalization of hour portion: "h" returns a 12-hour format of an hour with leading zeros, 01 through 12. "H" returns a 24-hour format of an hour with leading zeros, 01 through 23.