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
3 answers

Decrease month by one in strtotime?

all Decrease month by one in strtotime in this loop. $twitter_val7 .='{ date: new Date('.date("Y",strtotime($date)).', '.date("m",strtotime($date)).', '.date("d",strtotime($date)).'), value:…
Ajay Patel
  • 5,298
  • 11
  • 55
  • 87
-2
votes
2 answers

check more than one string in strtotime

I have this code to check if the mysql timestamp is 24 hours old, it works for one string however I need to check two strings but i'm not sure how to add it in if(strtotime($dateFrom." + 24 hours") <= strtotime("now")) for example i'd like to add…
Marc Howard
  • 3
  • 1
  • 5
-2
votes
1 answer

strtotime() ignores year when date is in "Y, F j" format in php

I have just noticed that if the date string is mentioned in "Y, F j" format then strtotime() function in PHP ignores the year while converting it to the Unix Timestamp and always return timestamp with current year For example, Lets take 2 dates with…
T.Prasad
  • 23
  • 3
-2
votes
1 answer

Timestamp in 5 days from today in at 0 o'clock

I am looking for a simple way to get a timestamp relative to today, but at a specific time. Example: Right now is 07-01-2020 10:00 a.m. Result: Time stamp of 06.07.2020 0 o'clock Only that the values of today are varbiale. Is there a good…
-2
votes
2 answers

Add string variable (minutes) to time variable in php

I got some problems handling string and time. I am reading a form which gives me a string like this: "08:00" Now i am running a foreach loop after which i want to add e.g. 15 minutes to the upper string. I tried to convert the "08:00" to a time…
Michael H.
  • 79
  • 1
  • 1
  • 11
-2
votes
3 answers

PHP get the last specific day

I need to calculate the last specific day from today, I looking for something like this: echo date('Y-m-d', strtotime("last 10")); // if current date is '2019-02-04' outputs '2019-01-10' // if current date is '2019-02-14' outputs…
Fabio
  • 31
  • 6
-2
votes
1 answer

How to call PHP Strtotime in AJAX looping function?

So I'm trying to call strtotime function inside ajax looping but i dont knw hw to call it ive surf everywhere , n i cant find 1 thread about date(strtotime) in ajax . heres my code, it return 01 Jan 1970 for every record loop '

-2
votes
4 answers

Get difference between time using strtotime returns different value

I have two different time in a 24-hr format which is time in and timeout. Given the scenario below: $timeIn = "19:00"; $timeOut = "09:00"; //calculated it using strtotime $timeDiff = strtotime($timeIn) - strtotime($timeOut); $timeDiff =…
Eem Jee
  • 1,239
  • 5
  • 30
  • 64
-2
votes
1 answer

How to add period to only TIME (02:00:00) in PHP

I want to add a specific period like 2 hours to only time. BUT only TIME. There will be no date related issue. Like my time is 02:00:00 And I want to add 1 hour to this time. So, the result will be 03:00:00 Is there any PHP built-in function…
Teenager
  • 23
  • 6
-2
votes
1 answer

Strtotime return a negative number

I want to get the difference time between Now and today midnight but I get a negative number. Why? echo strtotime('today midnight') - strtotime("now");
user3066977
-2
votes
1 answer

Not a duplicate : How to display date of next 6 months in php

I am working on loan slider calculation in which if user select any date from drop down then i have to show the ext 6 months date. for ex: if user selects the date "5" then next 6 dates would be which are i am getting now: 1 5th Dec 2017 2 5th Jan…
prakash tank
  • 1,269
  • 1
  • 9
  • 15
-2
votes
4 answers

PHP date function is returning wrong month and date

I have been working in PHP Development for 5 years but never seen this type of error before. I have a date which is the last day of the month and I am going to change its format with using below code : $data['toDate'] = "2017-04-31"; echo…
Hardik
  • 1,429
  • 2
  • 19
  • 37
-2
votes
1 answer

how to show a hotels opening or closing timings based upon working hours

in my database table i have stored start_at and end_at timings of hotels Here is my slim api php code ` $st_time = strtotime('Start_at'); $end_time = strtotime('end_at'); $stmt->execute(); $data=$stmt->fetchAll( PDO::FETCH_ASSOC); …
-2
votes
1 answer

PHP - Convert date format from YY/MM/DD to yyyy-mm-dd

i've a device that give me file logs with date format like this: 16/11/07 (today date) but when i'm trying to convert it with date() and strtotime, doesn't work and give me 1970-01-01. $row2 = "16/11/07;11:49:00"; $par = explode(";",$row2); …
maures
  • 131
  • 1
  • 2
  • 13
-2
votes
3 answers

Setting strtotime adding a variable to amount of days

I am trying to export a certain number of days and setting it to the variable $max_future. Currently it is a set amount of days but I want the users input variable to be the number it has instead. Currently it is set as: $max_future = date("Y-m-d",…
user5843278