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.
Related
This question already has answers here:
Convert Days to Year,Month,Day Format
(2 answers)
How to calculate the difference between two dates using PHP?
(34 answers)
Closed 2 years ago.
1st method: I've got x days and I want to convert it to weeks and month via php. For example 24 days:
3 weeks 3 days
or 45 days:
that's where my problem starts. How can I know that 45 days is how many month including month differentials?
2nd method: I've got two dates, for example 2020-05-13 and 2020-07-14. Can I calculate month, weeks, and days somehow from these?
I don't have any code since I don't even know how to start it.
This question already has answers here:
How to calculate the difference between two dates using PHP?
(34 answers)
Closed 6 years ago.
I want to count how many hours, minutes and seconds between two dates.
For example: Date 1: 01-01-1990 12:00 and 01-02-1990 13:00
Now, how many hours, minutes, and second from date 1 to date 2 using php?
just use strtotime() on your dates to their timestampz . and then subtract them to have the difference in the number of seconds. it's easy to convert from there
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
This question already has answers here:
PHP: Adding months to a date, while not exceeding the last day of the month
(7 answers)
Closed 7 years ago.
Hi I'm still new in PHP and currently I want to make system about Employee Allowance and have no idea how to start calculate months in php .For example Steve should get allowance for 4 months from now and database stored the result of calculation, so far the coding is:
?php
$date=date_create("2013-03-15");
date_add($date,date_interval_create_from_date_string("40 days"));
echo date_format($date,"Y-m-d");
?>
Months input is from user and stored in database.
I'm not sure I follow your 40 days versus 4 months, but I think you want something like this:
echo date('Y-m-d', strtotime("Now +40 days"));
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'