I am using following function and I want time in 24hr clock format but this gives me time in 12hrs:
<?php
date_default_timezone_set('Asia/Kolkata');
$timestamp = date("d/m/Y h:i:s", time());
print $timestamp ;
?>
What am I doing wrong?
I am using following function and I want time in 24hr clock format but this gives me time in 12hrs:
<?php
date_default_timezone_set('Asia/Kolkata');
$timestamp = date("d/m/Y h:i:s", time());
print $timestamp ;
?>
What am I doing wrong?
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, G
or H
give you the time in 24-hour format. You should read the manual.
date('H', time());