Skip to content

Tag: strtotime

Subtracting days from a future date

It is working as expected. $newdate prints as 1 December 2022 However, if the $tour_date is not the current year, it does not work properly. It is still printing as 1 December 2022. The $newdate prints as 1 December 2022. But it should be 1 December 2023 which is -10 days from 11 December 2023. Any idea, that…

Have I gone crazy, or has PHP’s strototime() broke? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 1 y…

Substract an amount of time to an addition of times

I have to substract 32:30:00 (string) to 95:05:00 (string) in php : THey are coming from an addition of time . I can’t find any code working, cause strtotime doesnt accept more than 24 as a value . Please help me, thank you. For example, i ve tried this : It returns 0 It should return something like 62:…

php strtotime in seconds and minutes

i use ths method to find the difference between two timestamp and get the number of seconds between those two times, and i refresh the information with jquery like a counter. When the difference is more than 60 seconds, the $time comes back to 0, like a reset. i would like to display 1 min XX s for example An…

How to get closest date compared to an array of dates in PHP

This post almost answered this question for me, but I have a specific need and didn’t find what I sought there. This lies right outside my experience; couldn’t quite wrap my head around it, so all I really need is a point in the right direction. Let’s say I have an array as follows: I would …

PHP strtotime() different results of monday this week

I have a problem getting the date of monday in the current week. When I’m running the above code on my local machine (PHP 5.3) it outputs correctly ‘2011-03-07’, but the same code on my server (PHP 5.2) outputs ‘2011-03-14’ (that’s monday next week). I’ve tried to run…

$date + 1 year?

I’m trying to get a date that is one year from the date I specify. My code looks like this: It’s returning the wrong date. Any ideas why? Answer To add one year to todays date use the following: For the other examples you must initialize $StartingDate with a timestamp value for example: Try this o…