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

strtotime() should return 0 if the argument is also 0

How can I get the function strtotime() to return 0 if the argument is also 0? In my example, $testvar2 returns "empty". $testvar = 0; $testvar2 = strtotime($testvar); print_r($testvar2);
MeTa
  • 89
  • 1
  • 3
  • 11
-3
votes
1 answer

Reset of Serial Numbers By Each Number by each month in php

I would like to create a serial number the following way. The serial number should go back to 01 with the start of each month. $stockno=dofetch(doquery("Select count(id) from vehicle",$dblink)); $stock_no=…
Behlum Noman
  • 421
  • 4
  • 5
-3
votes
2 answers

unexpected while-loop behavior

I've tried building and placing the while loop in different ways and different locations and looking at $val as the right/wrong variable to be placing in the while loop but I'm just not getting it. I expected output to be: 815 830 845 900.......…
DMSJax
  • 1,709
  • 4
  • 22
  • 35
-3
votes
2 answers

I have a specific value and i want to strtotime

I want to add a minute to the time which is the post posted Let say that $time_posted = "12:14" where 12 is hours and 14 minutes, what i actualy want is to add 1 minute to the $time_posted NOTE: $time_posted is for different posts different. Thanks…
Hamza
  • 721
  • 8
  • 8
-3
votes
3 answers

PHP fails to compare dates

I want to compare if given date is older then current date. Result of IF statement 'date is in the future' . Can someone tell me why PHP gives wrong result in IF statement? Here is code that I am using $date='17/06/2013'; $currentDate =…
user2496520
  • 881
  • 4
  • 13
  • 36
-3
votes
6 answers

PHP convert time strtotime working incorrect for me

I need to convert time, use PHP strtotime function. time have following format $date1 = 12:10:00 $date2 = 00:10:00 echo date( 'Y:m:d h:i:s', strtotime( $date1 )); // 12:10:00 echo date( 'Y:m:d h:i:s', strtotime( $date2 )); // 12:10:00 How I can…
styopdev
  • 2,604
  • 4
  • 34
  • 55
-3
votes
2 answers

PHP: Check if last storage time in the database is greater than 10min, and do stuff

I want to check if a device's IP has been stored before, if so, check if IP storage time and now() is greater than 10min and do stuff. here's my PHP to cheeck if IP is present in the database. $ip =…
Relm
  • 7,923
  • 18
  • 66
  • 113
-3
votes
2 answers

Get Date from Regional Datetime string

I want to fetch only date: 2013-09-24 from the following string using php: $2013-09-24T11:53:58+02:00am09pam53119_Tue, 24 Sep 2013 11:53:58 +0200Europe/Berlin58000000Tuesday30[0] I am getting above string from this line of code: $second_date = …
Jerry3456
  • 79
  • 7
-3
votes
2 answers

Getting wrong weeknumber from strtotime()

Hello my geeky fellows! I have this list of dates: 20-02-2013 19-02-2013 18-02-2013 17-02-2013 16-02-2013 15-02-2013 14-02-2013 13-02-2013 When i use strtotime() with these dates, I get…
ACetin
  • 97
  • 7
-4
votes
2 answers

PHP: Merge three variables (year, month, day) into one date

I have three variables: 1.) $year (e.g. "2018"), 2.) $month (e.g. "9" or "12"), 3.) $day (e.g. "5" or "21"). I want to merge them into one single variable ($date) in the format of YYYY-mm-dd, i.e. "2018-09-14". Note that the month "9" and the day…
anmipa
  • 93
  • 1
  • 8
-4
votes
2 answers

strtotime minus hours and minutes

I have this code: as you can see the time is changed by subtracting 6 hours from the time, what I want to subtract the hours and also…
Michele Petraroli
  • 89
  • 1
  • 1
  • 11
-4
votes
2 answers

PHP: Alternative to DateTime

I cannot use DateTime because of the version of PHP I am running. Can anyone suggest a way to get the equivalent value using strToTime or some other date function. I know this is probably an easy question but I am very rusty on dates in php. i.e.…
user1904273
  • 4,562
  • 11
  • 45
  • 96
-4
votes
2 answers

what is the most efficient way to get 1 or 2 day before the first day of week number and year in php with native functions

I need to use php to return the Saturday or Sunday before the given week number and year, for example: date('Y-m-d',strtotime("2011W011")) #returns '2011-01-03', but I need it to return '2011-01-01 or 2011-01-02 instead …
xam
  • 452
  • 2
  • 7
  • 15
-4
votes
4 answers

Php date and strtotime

i have some problem with strtotime , when i try to addimg 2 month to my current date Example : '2014-12-16 13' => date('Y-m-d H'); $compare_date = date('Y-m-d H:i',strtotime('2014-12-16 13'.'+2 month'));
Yra Yra
  • 1
  • 3
-4
votes
1 answer

Convert string to date using strtotime php

please i need help in converting string to date my string is $search = '6/2/2014' i used this way but it doesn't work correctly $time = strtotime('$search'); $newformat = date('DD-MM-YYYY',$time); echo $newformat; the result is displayed as…
1 2 3
87
88