Skip to content

Tag: date

Add ‘x’ number of hours to date

I currently have php returning the current date/time like so: What I’d like to do is have a new variable $new_time equal $now + $hours, where $hours is a number of hours ranging from 24 to 800. Any suggestions? Answer You may use something like the strtotime() function to add something to the current ti…

PHP get UK local time from Server in different time zone

I have a web server which I do not know what the time zone is set to. it is now 10:49am in the UK, but when I run the following: The server returns the following time. Now I don’t want to just “Add” one hour onto the time because the time still needs to be correct when time moves forward

PHP checkdate variants

I found a php function checkdate() , but strangely enough it only seems to accept data in format of int $month , int $day , int $year. However I am passing the date as a string (example “2012-06-13”) …

PHP Date Function Seven days previous

I am trying to use PHP’s Date Function to get the date of 7 days earlier in YYYY-MM-DD format. when i try i get an error Answer Use the strtotime method provided by PHP. date(‘Y-m-d’, strtotime(‘-7 days’)) Thanks to @lonesomeday for pointing out my mistake in the comments 😉

PHP string date + 1 day equals?

I have a date which is saved in a regular string. // format = DD-MM-YYYY $date = “10-12-2011”; How can I get the date-string +1 day so: 11-12-2011?

subtract 6 hours from date(‘g:i a’, strtotime($time_date_data));

I am using the following code to transform a universal time code into something a little more user friendly. But now I need to subtract 6 hours from meeting_time. Should I do it after the code above or can I work it into the same date function? Something like: Answer String-to-time (strtotime) returns a Unix …

How can I divide a date range by number of months?

My dilemma is that if I request more than 6 months or so ( I do not know the approximate number ) from my webservices ( which gets called via JS ), I get nothing back. In other words, I have to limit it to 6 months. So let’s consider this scenario: I need to split this up by 6