Why does a less than or more than comparison in PHP of two strings in the date format of “YYYY-MM-DD” work even though they are strings?

前端 未结 2 894
我寻月下人不归
我寻月下人不归 2021-01-05 00:31

I am working on a section of PHP code for a project that compares a date in the YYYY-MM-DD format to the current date to see if it is less than the current date. At differen

2条回答
  •  悲&欢浪女
    2021-01-05 01:15

    Use the DateTime class for comparing dates. It makes it a lot easier to understand, and you don't have to deal with type juggling.

提交回复
热议问题