Skip to content

Tag: date

Date conversion in PHP

I have date in the following format – I want convert this date using php in the following format – I tried following ways so far but id didn’t work – There are many questions already available for date conversion on stack overflow itself but none of them answer my question as my date t…

PHP: Trying to insert dates in Database

I want to insert all the dates between a starting and an end date into a table in my database. I already found a code for the two dates and the dates between. The problem now is that the dates are not inserted into my database when running the code. Only 0000-00-00 is displayed in my date table. Also no

How to know if a date/time string contain day or not in php?

I want to check if a date/time string contains a day or not. I used the date_parse() function but it automatically adds day => 1 if it doesn’t find any day. So I couldn’t know if a string contains a day or not. For example How to know if this string contains a day or not? Answer I think you

PHP UTC String to date

I have a problem. In my code I have the following line: The goal is to get the previous and next hour, so I tried this: But then the I get the following result: Because of my timezone (+1) the RunDateTimeGMT0 gets converted to a date of my timezone. I want the following result: How can I keep the date

PHP, MySQL date calculations

I’m trying to add a number of weeks to date, both will be taken from a database, I successfully fetch both needed but I can’t figure out how to make the calculations. So far I tried with “strtotime” but it gave me some weird results How do I do this the right way? The desired result sh…

Query database for last modified date

I am trying to query my WordPress server to echo the date of the last modified post. In this case the database name is local and I am checking the posts table. My current code is close to what I need, it will display the date and time as Y-m-d H:i (2021-01-13 12:18) How do remove the time and display

PHP month before last

I have used date(‘F’, strtotime(‘last month’)) successfully to get the name of the previous month (currently December) but how to I get the month before last (currently November)? Looking at https://www.php.net/manual/en/datetime.formats.relative.php this doesn’t appear to be a b…