I’m using strtotime($my_time); to create timestamps that I use in php math.
The variable $my_time is in HH:mm:ss 24h format pulled from the database.
I’m setting the time but I don’t know what date is being produced. For this reason I’m trying to set a fixed date. I tried the followng but I’m getting wrong results in my calculations.
strtotime('2007-12-21', $my_time);
strtotime( '+1 day', strtotime('2007-12-21', $my_time); //should produce 2007-12-21 00:00:00 ?
Please help me understand how to set a fixed date in strtotime() and dynamic time?
note: the DateTime class isn’t an option in the code I’m using.
You should concatenate the strings into one argument, not providing two arguments.
I’ve also switched to 1970-01-01 as the date because that’s when UNIX timestamps begins, which gives you seconds only to work with. It may be easier to troubleshoot that way because you can see at a glance if one number is bigger than another, you can also easily spot failures such as >86400 and so on.