Questions tagged [strtotime]

PHP function for parsing about any English textual datetime description into a Unix timestamp

Samples

strtotime('first day of this month');
strtotime('last day of this month');
strtotime('-1 month'); # current date -1 month
1308 questions
5
votes
4 answers

strtotime: Check for time

I have a voucher system, where I can enter a date or a date with a time. There should be all valid formats allowed, for example this ones: 01.01.2016 01.01.2016 00:00:00 This I no problem, if I have the start date for a voucher, but it is a…
Richard
  • 2,840
  • 3
  • 25
  • 37
5
votes
1 answer

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

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…
Michał Pękała
  • 2,359
  • 5
  • 22
  • 32
5
votes
4 answers

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

echo $_POST['time']."
"; echo $_POST['day']."
"; echo $_POST['year']."
"; echo $_POST['month']."
"; 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
Abhishek
  • 113
  • 1
  • 2
  • 10
5
votes
2 answers

PHP: strtotime returns "nothing" of type "boolean"

I have the variable $EDate, I used strtotime function with this variable with different values and the result was as following: $EDate = 10-21-2013; echo "strtotime($EDate)"; the result = nothing and the type is boolean $EDate = 09-02-2013; …
Marmar
  • 51
  • 5
5
votes
1 answer

strtotime('0000-00-00 00:00') return negative value

Php strtotime('0000-00-00 00:00') showing strange behavior. Its returning negative value something like -62169984000. I have Php version 5.4.17 in my 64-bit System. It should return false value which is expected. But when I checked in other…
pankaj
  • 43
  • 1
  • 11
5
votes
5 answers

Comparing two Dates using strtotime() in PHP

I have two variables containing strings of dates in the format $four_days_have_passed = "07-14-2013"; $now = "07-10-2013"; I have checked the output in FirePHP and the dates are correct. Then I try to compare them like this, if (strtotime($now) <…
David Folksman
  • 225
  • 3
  • 8
  • 24
5
votes
2 answers

Check if current time is between two times, with the possibility of lapping days

I have a system that accepts user submissions, and upon receiving a submission the system will go through all timeslots to find the appropriate timeslot. The problem is that it needs to be able to check against the start & end times if the end time…
user1767172
5
votes
4 answers

Convert specific string to time in PHP

I need to convert a string into date format, but it's returning a weird error. The string is this: 21 nov 2012 I used: $time = strtotime('d M Y', $string); PHP returned the error: Notice: A non well formed numeric value encountered in index.php…
Dênis Montone
  • 581
  • 2
  • 7
  • 18
5
votes
3 answers

PHP : strtotime() returns always 01/01/1970

I am trying to display dates in the European format (dd/mm/yyyy) with strtotime but it always returns 01/01/1970. Here is my codeline : echo "

".date('d/m/Y', strtotime($row['DMT_DATE_DOCUMENT']))."

"; In my database, the field is a…
HerrM
  • 489
  • 2
  • 6
  • 13
5
votes
6 answers

PHP date strtotime not working

I wrote this piece of code echo date("Y-m-d", strtotime($date, strtotime("+ " . $days . " days"))); $date = 2012-04-12 $days = 15 I am looking to add $days (15 days) to the date (2012-04-12) I am expecting to get 2012-04-27 and this code returns…
user979331
  • 11,039
  • 73
  • 223
  • 418
4
votes
3 answers

fullCalendar daylight savings time error

I have a an application built with the jQuery based fullCalendar http://arshaw.com/fullcalendar/ My calendars events are loaded by an Ajax call that outputs JSON, it is configured to have Monday as the first day of the week and the default view is…
Kevin Bradshaw
  • 6,327
  • 13
  • 55
  • 78
4
votes
2 answers

How do I make dates legit/safe before passing it to strtotime()?

Here is what I have now. $date = mysqli_real_escape_string($dbc, trim(date('Y-m-d',strtotime($_POST['date'])))); I was told that I need to make sure that the $date is safe/legit before passing it to strtotime(). How do I do that? I've looked up…
Matt Ridge
  • 3,633
  • 16
  • 45
  • 63
4
votes
3 answers

32 hours ago excluding weekends with php

So I have a script that does multiple checks for 32, 48 and 72 hours ago. Basically I check my database for entries that are at least x hours old. Now this works fine like this: $date = date('Y-m-d H:i:s',strtotime('-32 hours')); $q = "SELECT *…
Kokos
  • 9,051
  • 5
  • 27
  • 44
4
votes
5 answers

php - add two hours to date variable

I want to add 3 minutes to a date/time variable I have, but I'm not sure how to do this. I made the variable from a string like this: (which is in the RFC 2822 date format btw) $date = 2011-10-18T19:56:00+0200 I converted that string into date…
laarsk
  • 862
  • 6
  • 17
  • 36
4
votes
5 answers

PHP strtotime() function

I have a file with the following lines. I want to identify lines which have timestamps less than a week from now(starting from aug 22 for this example). log3.txt 28-08-2011 10:29:25 A string 29-08-2011 14:29:25 A new string 20-08-2011 14:29:25 Don’t…
theking963
  • 2,223
  • 7
  • 28
  • 42