5 minutes past midnight?

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
GlennLittleford
New php-forum User
New php-forum User
Posts: 2
Joined: Sun May 19, 2019 3:49 am

Sun May 19, 2019 4:04 am

Hi

Getting a unexpected response to this code to get the time for midnight of today.

strtotime(date("Y-M-d",time()))

For some reason it returns a time 5 minutes after midnight, eg

date("Y-m-d H:m",strtotime(date("Y-M-d",time()))) returns 2019-05-19 00:05 instead of 2019-05-19 00:00

I also tried date("Y-m-d H:m",strtotime('today midnight')), same deal, 5 minutes after midnight.

Am I missing something? Php 7.1.7 on a 64 bit Windows server.

Thanks
Glenn

GlennLittleford
New php-forum User
New php-forum User
Posts: 2
Joined: Sun May 19, 2019 3:49 am

Wed May 22, 2019 4:14 pm

OK, sorted it. Someone on another forum pointed out the obvious. I was using "Y-m-d H:m", "m" is month, should have been "i" for minute. Shows I come from a VB background.

chorn
php-forum Fan User
php-forum Fan User
Posts: 601
Joined: Fri Apr 01, 2016 2:18 am

Wed May 22, 2019 10:21 pm

thx for clarification, i didn't see that.

Post Reply