Matt
Matt

Reputation: 105

24 hour format for the actual time?

I would like to get the actual date + time, and convert it (the time) to a 24 hour format (e.g: 15/04/2017 13:32:02)

My current code is :

date_default_timezone_set("Asia/Magadan");
$date = date("d/m/Y h:i:s");
echo $date;

That display :

15/04/2017 01:32:02

Thanks.

Upvotes: 2

Views: 6509

Answers (3)

hosein moradi
hosein moradi

Reputation: 492

convert (h:i:s) to (H:i:s) . that's worked for me

Upvotes: 0

Altaf Hussain
Altaf Hussain

Reputation: 191

Put the h capital for 24 hour format date("d/m/Y H:i:s");

Upvotes: 4

Matt
Matt

Reputation: 105

Finally, to change to a 24 hour format we only have to change the H of the hour to a MAJ/CAPS.

$date = date("d/m/Y H:i:s");

http://php.net/manual/en/function.date.php

Upvotes: 1

Related Questions