Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php date before 1970

im using PHP 5.3 and have read alot of material in that matter but still cant fins a solution.

I want to import birthdays 01/10/1945 from excel into mysql using php whatever i tried did not give me the result (im getting a negative number)

here is the last solution that i have tried :

$data is the excel file (im using excel reader class for that)

$date_of_birth = ($data->sheets[0]['cells'][$i][11] - 25569) * 86400;

the result was -2207692800

what am i doing wring here ?

like image 885
lior r Avatar asked May 30 '13 14:05

lior r


1 Answers

Dates before the Unix epoch are represented as negatives in PHP, so you're not doing anything wrong.
When you use any of the date time functions on the timestamps, you'll get the correct value.

like image 197
Emmanuel Okeke Avatar answered Oct 18 '22 16:10

Emmanuel Okeke