16

FUCK YOU PHP, WHY THE FUCK DO YOU GIVE ME DECEMBER 1ST WHEN I DO
strtotime('-1 month', '12/31/2015)
USING DateTime PRODUCES THE SAME FUCKING RESULT. ARE YOU FUCKING RETARDED OR WHAT?
YEAH I KNOW NOVEMBER DOESN'T HAVE 31ST BUT YOU COULD AT LEAST RETURN 30TH OR EVEN RAISE A WARNING, YOU FUCKING PIECE OF SHIT.

Comments
  • 1
    Well, it sure as hell can't give you November 31st 2015.
  • 5
    Almost every time format ever will give you that. Dates aren't what you want them to be, they're the seconds since UNIX epoch, so if you subtract an int of seconds to get the 31st of a 30 day month, obviously, you'll just get the day after the 30th... it grabs the seconds, then converts it to a Date format. There are too many fringe cases to try to error out every time someone messes that up, most people prefer this format.
  • 0
    Atleast it's consistent... What are you trying to get? The last day of the previous month?
  • 2
    Doesn't matter what language you use, working with date and time with high precision is always hard. So always use a library that specialize on it. carbon.nesbot.com is a great one for php.

    On the other hand, 1 month is generally 30 days so isn't quite logical that it returns 1/12/15? cmiiw
  • 2
    Make use of the Carbon package if you can. It gives you great power when it comes to dates.
  • 0
    @fan1200 same formula, same results...
  • 0
    @Meki If your goal is to get the last day of the previous month. Then it can be made easy by using this package. If he wants to go back a month but the month doesn't has that day. Well, then you're going to have a bad time.
  • 0
    @fan1200 believe me, I know :)
  • 0
    @xNeko well said.
  • 0
    if you are frustrated just create a new library to mend your frustration. This is how projects are born.
Add Comment