This question already has answers here:
Accessing dates in PHP beyond 2038
(5 answers)
Closed 7 years ago.
I need a date which is 35 years ahead of a date which is user input.
With the following code in php
$DoCndm=date("Y-m-d",strtotime($_POST['DoH'] ." +35 years"));
I found that it works correctly upto 22 years but returns output as 1970-01-01 for 23 and above.. Is it a bug ??
Read this link Year 2038 problem
You can not use unix timstamp above 2038 year
Related
This question already has answers here:
Get week number (in the year) from a date PHP
(18 answers)
Closed 2 years ago.
For Example, when I give it 01/01/2020 it should know that it's week 1 or 12/03/2020 it is week 13. All this in a Laravel app.
If it implements DateTimeInterface You can use DateTime::format() method with 'W'. More info and usecases here.
This question already has answers here:
Wrong month (February) - DateTime::createFromFormat [duplicate]
(2 answers)
Closed 5 years ago.
So this appears to only be happening today, but this does not seem right to me. I encountered it converting dates from one representation to another, I was not having this problem on other days.
Interactive shell
php > print_r(DateTime::createFromFormat('n Y','5 2017')->format('YM'));
2017May
php > print_r(DateTime::createFromFormat('n Y','6 2017')->format('YM'));
2017Jul
Am I missing something? My expected output for the second statement is "2017Jun"
This is a duplicate of Wrong month (February) - DateTime::createFromFormat
If you do not give it a day it uses today's date as seed.
Since 31/6/17 does not exist it rolls over to the next month.
This question already has answers here:
How to calculate the difference between two dates using PHP?
(34 answers)
PHP - Find the difference between two times
(6 answers)
Closed 5 years ago.
I have a datetime format from an API that is formatted as so:
Thu, 17 Nov 2016 19:12:12 GMT
I am unsure how to format this in PHP to something that I can check for an hour difference. The problem is that this not one of the standard date time constant formats in PHP: http://php.net/manual/en/class.datetime.php
The 3 letter day and GMT timezone in the end is what's mostly tripping me up here.
This question already has answers here:
Calculate time elapsed in php - spans over 24 hours
(2 answers)
Closed 9 years ago.
I have been searching for a while now regarding on how to format hours in php that will show 000:00:00 instead of 00:00:00.
I need this to calculate the duration of records with start and end Date with a datetime data type in mysql.
The problem with my current format ('H:m:s') is it only count 24 hours and when the duration goes higher than that, it will show 01:00:00 instead of 25:00:00.
Try TIMEDIFF() function in MySQL
Example:
SELECT TIMEDIFF('2008-12-31 23:59:59.000001',
'2008-12-30 01:01:01.000002');
-> '46:58:57.999999'
This question already has answers here:
How can I work with dates before 1900 in PHP?
(2 answers)
Closed 9 years ago.
I have to manage every type of date.. I'm looking for the best way to manage date such as 600.000 a.c.e. or 5.000.000 years ago and the other kind of date format possible from the born of the earth
what would you suggest?
I'm blocked using a string format like: yyyyyyyyyy.mm.dd.v
where v is the ACE/BCE variable
[edit]
if I start counting the day from the born of the earth, so 4.5mil years ago is the 1st day?
You can use any number of seconds as your timestamp(consider your arch, of course)
Just remember any date is in seconds.
php > echo date('Y.m.d', 9000000000000000), "\n";
285200616.07.24
php > echo date('Y.m.d', -9000000000000000), "\n";
-285196677.06.10
As for AC/BC flag you must compare your timestamp to be lower than - 1970 years in seconds
EDIT
There's seems to be a problem in years between 1000 BC an 0 BC if you are using Y flag. The year becomes 0013 for 13 BC, so you should consider additional parsing for this range of years.