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

Get Unix timestamp of specific date after another specific time

I can get the for example 19 March of specific date with this code: $date = strtotime(" 19 March", $current_time); For example if I gave the unix timestamp of 1st of January of 2010 as an input, It gave me 19 March of 2010. But also if I gave the…
Shadi Hariri
  • 197
  • 16
-2
votes
2 answers

strtotime() Get 7th day of -1 month

I have tried : $firstOfMonth = "2015-01-01"; $last_month = date("Y-m-d", strtotime('first day of -1 month', strtotime($firstOfMonth))); /* ^^^^^ This gives me 01 of last month */ /*** Tried 'seventh day of -1…
Alex
  • 626
  • 7
  • 16
-2
votes
1 answer

PHP Check to see if date is older than X number of days

I have searched this topic and came up with some answers but they don't seem to work. I am a beginner at PHP and I need to create a variable that tells if a clients original order date is older than 52 days from the current date. Here is what I have…
-2
votes
3 answers

strtotime(); Problems with posted data

I am posting a time value from one page to another using html input type time. The posted value is displaying correctly but it doesn't show any output after applying strtotime(). Here is my HTML code
Abey
  • 1,408
  • 11
  • 26
-2
votes
1 answer

the first day of the month

I'm trying to build my agenda in php, using strtotime to return dates based on what wants the user, but I observe an understood issue whith strtotime! When I say Fisrt Monday of Septembre 2014 it gives me 08 September. normaly it should return 01…
-2
votes
3 answers

False dateresult using date() php

I want to parse the date 1938 1938+02:00 using date() & strtotime(). My code: echo date("Y", strtotime("1938+02:00")); gives me as result "2014".. What am i doing wrong?
R2D2
  • 743
  • 1
  • 7
  • 14
-2
votes
1 answer

Add hours to timestamp without converting to unix?

I need to add +7 hours to a timestamp I'm getting from the DB, but I can't change it to unix because I'm using a function to convert it to "2 hours ago" and stuff like that. How would I go about doing this? Every question I've seen uses strtotime()…
impedans
  • 3
  • 4
-2
votes
1 answer

Get date of next years first week strtotime

I'm trying to get the date of the first week in 2015 and its really frustrating. This works: strtotime("2014W17-1") it returns 2014-04-27 But when I call: strtotime("2015W1-1") it returns 1970-01-01 Hmm. Whats wrong ? Thanks!
Thomas Bolander
  • 3,892
  • 3
  • 22
  • 30
-2
votes
5 answers

Correct way to add days

I've tried to add 7 days to 2013-10-26 and got back 2013-11-01. But it have to be 2013-11-02. My old function was something like this: public static function add($date, $years = 0, $months = 0, $days = 0) { $date = explode('-', $date); …
ortreum
  • 53
  • 6
-2
votes
1 answer

PHP datetime different in minute?

I have two date time, date1 = '2012/10/18 14:12:12' date2 = '2012/10/18 14:20:12' and the date2-date1 is 8 in minute. I want to get the diffrent in minutes. But if the date2 > date1 date1 = '2012/10/18 14:02:12' date2 = '2012/10/18 14:10:12' Then I…
RJaniii
  • 25
  • 6
-2
votes
4 answers

How to display a formatted weekdays from a given Week number

I'm getting the weekdays from a given week number and year using the php below: $week_number = 42; $year = 2014; for($day = 1; $day<=7; $day++) { echo date('m/d/Y',strtotime($year."W". $week_number.$day)); } The Output look…
ilp
  • 87
  • 1
  • 7
-3
votes
2 answers

Weird Response of strtotime PHP

I have a code where I'm using strtotime() to get the date timestamp in PHP. Have encountered a weird response of it. Case 1. I got a date like "Tue Jul 2 6pm" : strtotime gives bool(false).
Vivek Tankaria
  • 1,301
  • 2
  • 15
  • 35
-3
votes
1 answer

strtotime("1/1/2019 12:00 AM") I want the year to be variable so I don't have to change it every year

I'm doing an if/else statement for posting different info at different times of year. I want the years to be variable though so I don't have to change them every year. strtotime("1/1/2019 12:00 AM"))) && (time() <…
-3
votes
1 answer

PHP Build calendar that loops through until current month

I have a project im working on while learning PHP. I need to create a page that displays a link for a year and the months of that year on one line. Then it breaks and goes to the next year. Continuing this until the current year stopping at the…
aarmfield
  • 67
  • 8
-3
votes
1 answer

Add an hour to a time value on php

I have a form that people are filling in and adding appointment times to, im then inputting the form into a sql db. Im then making a sheet and that shows the appointment slot. All that I need to to is add 1 hour to the appointment slot time. I have…