Skip to content
Advertisement

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 will work

new DateTime is not working properly with the future date

I am trying to calculate the differences between 2 dates. The first date is the reservation date, and the second date is the traveler’s birthdate. Format of the $tour_day is 15 December, 202X It works if the reservation date is the current year. However if the reservation date is 2022 or more, than it cannot calculate correctly because is always

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 year ago. Improve this question

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:35:00 Do

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 Answer

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 like to have a

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(‘W’) on both machines and I get the same result (10). Edit:

$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 or

Advertisement