Noman
Noman

Reputation: 4114

PHP strtotime function with zero hours and zero minutes give unexpected result

why it is giving me wrong result when convert the time is 00:00. its

date_default_timezone_set("Asia/Karachi");
echo  date("G:m", strtotime("00:00"));
echo  date("G:m", strtotime("00:06"));

Output:

0:06
0:06

Upvotes: 0

Views: 1035

Answers (1)

n-dru
n-dru

Reputation: 9430

Change:

"G:m"

to

  "G:i" or "H:i"

m means month, not minute (hence you see 06 for June).

G is for hours 0-23 without preceding zeros

H is for hours 00-23 with preceding zeros

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

Upvotes: 2

Related Questions