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
4
votes
2 answers

PHP strtotime returning false for dates less than 1900

I know this question is very popular Asked here PHP: strtotime is returning false for a future date? and here How can I work with dates before 1900 in PHP? Could you please confirm my choices: Upgrade to a 64bit architecture Replace the…
hbt
  • 1,011
  • 3
  • 16
  • 28
4
votes
2 answers

strtotime PHP, display date/time

I have an XML file with a "Time" attribute. I am calling this XML into my PHP and giving it the variable $game_time. An example value for the attribute is "10:30 PM"... Since it is coming from XML, it is reading "10:30 PM" as a string. Now my…
John Stamos
  • 103
  • 6
4
votes
2 answers

PHP strtotime result is diffent in php7.3.2 and php7.3.1

just less than 1900,more than is normal. php version is 7 example: date_default_timezone_set('PRC'); $sbegintime = strtotime('1900-01-01 00:00:00'); var_dump($sbegintime);exit; php7.3:-2209017600 php7.2:-2209017943 why? Demo ~…
4
votes
3 answers

php strtotime not working

so I converted this string to timestamp using strtotime: strtotime("1 Nov, 2001"); which results into the timestamp 1320177660 but then when I tried converted 1320177660 into a normal date format again using an online timestamp converter, the year…
kamikaze_pilot
  • 14,304
  • 35
  • 111
  • 171
4
votes
0 answers

PHP - Using STRTOTIME in CASE STATEMENT for two Columns in DB

I want to use strtotimefor two date columns in the database in the CASE statement. This is the entirety of the php code.
Raven Pete
  • 41
  • 3
4
votes
1 answer

PHP distinguish between only-date or only-time as well as both

I am posting this optimistically after searching for an answer here on SO, and even when SO tells me my question might be closed, as I think in this case it's a valid question. Consider a CSV file with a column containing string representing either…
Oliver Williams
  • 5,966
  • 7
  • 36
  • 78
4
votes
2 answers

strtotime() & date() weird behaviour when converting date in to same format as it was before

I have to convert date format in to mm-dd-yyyy I don't know what is the current date format it is dynamic so if I have dynamic date format is already in mm-dd-yyyy then date() function is returning below outout $date='02-13-2011'; echo…
Shakti Singh
  • 84,385
  • 21
  • 134
  • 153
4
votes
3 answers

PHP strtotime giving the wrong date for certain months

the following code. strtotime("first saturday", strtotime("+2 month")); Is working correctly but with the months of April +2 month, October + 8 month, and December + 10 month is giving the second saturday in that month not the first. Any ideas what…
Walrus
  • 19,801
  • 35
  • 121
  • 199
4
votes
3 answers

Issue with php strtotime function when using ordinal values

I sometime get unexpected results when using ordinal values with strtotime. For example, why does date("M j", strtotime("second Tuesday February 2011")) result in "Feb 15" (which is actually the third Tuesday in 2011?
jalperin
  • 2,664
  • 9
  • 30
  • 32
4
votes
4 answers

Dynamic set increment time by 15 minutes

I have trouble to increment time by 15 minutes to end time. I tried date("H:i:s", strtotime('+15 minutes', strtotime($startTime)));. But it is not dynamic. Here i have starttime and endtime. $startTime = '09:00:00'; $endTime = '11:00:00'; And want…
Jaydeep Mor
  • 1,690
  • 3
  • 21
  • 39
4
votes
4 answers

How to add minutes and hours to a time string using jquery

I want to add 30 minutes and then one hour to my variable which i already have my own date var initialDate = '10:00'; So if (some condition){ // i add 30 minutes ->10:30 }elseif(another condition){ // i add 1hour ->11:00 } I tried this…
prince
  • 103
  • 1
  • 1
  • 10
4
votes
1 answer

Is strtotime() having a bug?

Consider this code where we want to add or substract one second: date_default_timezone_set("Europe/Amsterdam"); $time = 1477789199; echo $time . ' - ' . date('r', $time) . "\n"; // 1477789199 - Sun, 30 Oct 2016 02:59:59 +0200 This is correct,…
nl-x
  • 11,762
  • 7
  • 33
  • 61
4
votes
4 answers

What is the performace of PHPs strtotime()?

I am doing some large timestamp-list iterations: Putting them in tables with date-ranges, and grouping them by ranges. In order to do that, I found strtotime() a very helpfull function, but I am worried about its performance. For example, a…
berkes
  • 26,996
  • 27
  • 115
  • 206
4
votes
4 answers

How to calculate the interval between 2 unix timestamps in php WITHOUT dividing by 86400 (60*60*24)

I have 2 unix timestamps, I'm in AsiaPacific/Auckland timezone (GMT+12, DaylightSavings = GMT+13) I want to calculate the number of days interval between 2 timestamps, where one is inside daylight savings time and one is not. My example dates are: 7…
samsong
  • 113
  • 1
  • 7
4
votes
3 answers

Laravel 5.2+ date before and after date validation not working

This works 'expected_at' => 'date|after:"2016-04-09 10:48:11"', And this works $rules['expected_at'] = 'date|after:'.$opportunity->created_at; This does not work 'expected_at' => 'date|after:created_at', The "created_at" value in the database is…
Matthew Malone
  • 463
  • 1
  • 9
  • 26