Is there any difference in strtotime +day or +days?
Asked Answered
J

1

13

Was googling this, but couldn't find the answer. Was wondering, if there is a difference in these two scripts?

+3 day:

echo date( 'd.m.Y H:i:s', strtotime( '+3 day' ) );

+3 days:

echo date( 'd.m.Y H:i:s', strtotime( '+3 days' ) );

The output is exactly the same.

So is that implemented to make sure people get less errors or what?
And witch one should be preferred to use?

Juliusjullundur answered 20/9, 2012 at 9:11 Comment(0)
Y
23

That is basically same thing, and for usability and pretty purposes:

strtotime( '+1 day' );
strtotime( '+3 day' );
strtotime( '+1 days' );
strtotime( '+3 days' );
strtotime( '+1 weeks' );
strtotime( '+3 week' );

You can use the one you like more, basically the one that defines de number, 1 day, 3 days

Youngran answered 20/9, 2012 at 9:13 Comment(2)
I understand that they are for easy purpose uses only, but why isn't there one standard but multiple options?Juliusjullundur
Because of the user. And PHP is not a strict language.Youngran

© 2022 - 2024 — McMap. All rights reserved.