strtotime

Getting all dates for Mondays and Tuesdays for the next year

I need to output a list of dates (only Mondays and Tuesdays) for the next 12 months from current date like so: Jan 2010 Tue 12 Jan 2010 Mon 18 Jan 2010 Tue 19 Jan 2010 Mon 25 Jan 2010 Feb 2010 Tue 02 Feb 2010 Mon 08 Feb 2010 Tue 09 Feb 2010 Mon 15 Feb 2010 Tue 16 Feb 2010 Mon 22 Feb 2010 Mar 2010 Tue 09 Mar 2010 Mon 15 Mar 2010 Tue 1...

PHP date issue - strtotime does not output what it's supposed to?

Hi! I have a couple of blanks DATETIME values(0000-00-00 00:00:00) in my database. Whenever i run those through strtotime, they return "1263247058" instead of FALSE, which it should do according to the info on the linked page: http://stackoverflow.com/questions/1224680/php-strtotime-outputs-nothing How come? Thanks. ...

Convert date using strtotime from DOMDocument element

Hi there I'm parsing some data using DOMDocument after fetching HTML file using curl. The codes look like this $dom = new DOMDocument(); @$dom->loadHTML($content); $tables = $dom->getElementsByTagName('table'); $rows = $tables->item($tblNum)->getElementsByTagName('tr'); foreach ($rows as $row) { $cols = $row->getElementsByTagNam...

How to use the mysql "LIKE" syntax with a timestamp?

I want to allow my users to search the database for a row that was submitted on a certain day. The date is entered into the field in the database using the date() function which is great, but when i use the php strtotime function, of course the dates are not exactly the same. Is there some clever mysql function that can help me with thi...

PHP strtotime() looks like it is expecting a Euro format

I've been using PHP's strtotime() method to accept a date field on a form. I love how powerful it is, in how it will accept "Tomorrow", "Next Thursday", or (supposedly) any date representation and convert it to the Unix timestamp. It's been working great -- until yesterday. Someone entered "2-4-10" and instead of logging Feb 4th, 2010, ...

php - mktime or strtotime?

I'm trying to convert 2010-02 to February, 2010. But, I keep getting December, 1969 I've tried using mktime, strtotime, and some combination of the two, but still haven't been able to do it... This is what I tried most recently... $path_title = date('F, Y', mktime(0,0,0,2,0,2010)); ...

php why does it keep adding 2 minutes?

When it's pulled from the db, it comes out like this: 2010-02-28 10:00:00 I'm formatting it (yes, I know that it's better to just do it in the query, but I don't have that option right now): date('l F d, Y h:m A', strtotime($row['start'])); But, no matter what, it outputs like this: Sunday February 28, 2010 10:02 AM Any idea why i...

php strtotime problems, giving incorrect values?

I have this code: $date = '2010-03-08 8:10:20' $new_date = date('Y-m-d H:i:s', strtotime($date . " +1 month")); echo $new_date; Btw, I already set date_default_timezone_set('Europe/London'); And the result is: 5 April 2010, 3 days missing. Why is it happen? I heard they are some bugs in strtotime? If thats the case, how to get a c...

How to make strtotime parse dates in Australian (i.e. UK) format: dd/mm/yyyy?

I can't beleive I've never come across this one before. Basically, I'm parsing the text in human-created text documents and one of the fields I need to parse is a date and time. Because I'm in Australia, dates are formatted like dd/mm/yyyy but strtotime only wants to parse it as a US formatted date. Also, exploding by / isn't going to w...

Searching Database by Arbitrary Date in PHP

Suppose you have a messaging system built in PHP with a MySQL database backend, and you would like to support searching for messages using arbitrary date strings. The database includes a messages table, with a 'date_created' field represented as a datetime. Examples of the arbitrary date strings that would be accepted by the user sho...

Why is PHP date() adding +1 hour in diff calculation?

Hi there, I've got kind of a tricky question, I already searched every related question on Stackoverflow and neither solved my conundrum, although I think I'm running in circles, so here's the question: I've got this code: $val = (strtotime('2010-03-22 10:05:00')-strtotime('2010-03-22 09:00:00')) This returns correctly $val = 3900 ...

Start and end time, split into 1 hour segments.

I have a start and end time in a timestamp format. I want to split these into timeslots of e.g 1 hour. $t1 = strtotime('2010-05-06 12:00:00'); $t2 = strtotime('2010-05-06 18:00:00'); $timeslots = array(); while ($t1 < $t2) { $t1 = $t1 + 3600; $timeslots[] = $t1; } foreach ( $timeslots as $slot ) { echo date("Y-m-d H:i:s", $slot) . '<...

Converting from a day of week to unix time in PHP

Hi, I'm trying to get the unix time for date strings that are formatted like so: 'second sunday of march 2010' 'first sunday of november 2010' I was under the impression that strtotime could handle such a string, but apparently not, as this returns false. How can I convert to unix time when given a day of week, which one of those in t...

PHP strtotime( YYYY-mm last day) a month off error

I'm trying the following command in PHP 5.2.12 : print (date('Y-m-d', strtotime('2009-12 last day'))); Regarding to the php.net manual : date('m/d/y', strtotime('2009-03 last day')); # 03/31/09 it should display the last day of march 2009 (2009-03-31) ! Mine returns the last day of the previous month ? why ? : 2009-11-30 ...

Trying to find the previous six days given any date...

I'm using strtotime just fine for finding the previous week and next week's entries in my database, but what I can't seem to find is how to find the previous six days if the user selects a past date. Here's how I know what today and six days previous are: $today = date("Y-m-d"); $minus6 = date('Y-m-d', strtotime('-6 days')); Now how ...

In PHP given an extended date string, how can I extract the month Year in long format?

My attempted solution was: $date = "Nov 30 2009 03:00:00:000PM"; echo date("F Y", strtotime($date)); Expected result should be: "November 2009" Any other simple solutions? ...

How to convert date and time into unix timestamp in php?

echo $_POST['time']."<br/>"; echo $_POST['day']."<br/>"; echo $_POST['year']."<br/>"; echo $_POST['month']."<br/>"; I have value store like this now I want to create a timestamp from these value. How to do that in PHP? Thanks in advance ...

get date from string php - UK date

Hi-- I have a UK date in the format "06/Apr/2010 13:24" that I need to insert into a mysql db date field. The PHP strtotime function can't handle this string-- has anyone got any ideas other than writing a custom function? Thanks! ...

How can I get Rails to interpret a text field as a datetime

My database has a datetime field, and I want to be able to create new entries. Obviously the Rails datetime_select helper isn't the most user friendly thing to have in your form. I'd rather have a text field for the datetime (or one for the date, and one for the time) and interpret the inputs like PHP strtotime can. I might just be sea...

Drupal CCK Date: how to set datetime field's default value to a fix date?

Hi, I have a CCK datetime field and would like to set its default value to 31 May 2011. When I go to the configuration of the field I can set the default value to Now, Blank or Relative. Relative is to be set by a PHP's strtotime argument. However, it fails when I set it to 31 May 2011 --> I get today in the node add form last day of...