voducthang / php-excel-reader

Automatically exported from code.google.com/p/php-excel-reader
0 stars 0 forks source link

Date format Conversion problem #127

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have upload the excel sheet to mysql database using the php excel reader

here i have problem with date format:

1. my date format in excel sheet 12/09/2011 (DD/MM/YYYY).

2. here i'm convert date in using 

$variable=date('Y-m-d',strtotime($date_variable));

after the conversion 
my date is 2011-12-09 (Y-m-d)

month is date is working wrong .

what will do now?

Original issue reported on code.google.com by maniprak...@gmail.com on 22 Sep 2011 at 6:47

GoogleCodeExporter commented 9 years ago
i use php excel reader 2.23 and i got the same issue yesterday.
My date format was DD/MM/YYYY. I solved the issue by modifying 
excel_reader2.php corresponding to the format i wanted to use in excel

here is how i solve the issue :  
1 - open excel_reader2.php

2 - search for "$dateFormat"

3 - then change all formats starting with "m/d" to "d/m" and "m-d" to "d-m". 

example for me at line 688 i changed the two following format "m/d/Y" to 
"d/m/Y" and "M-d-Y" to "d-M-Y". the full line is now : 

var $dateFormats = array (0xe => "m/d/Y", 0xf => "M-d-Y", 0x10 => "d-M", 0x11 
=> "M-Y", 0x12 => "h:i a", 0x13 => "h:i:s a", 0x14 => "H:i", 0x15 => "H:i:s", 
0x16 => "d/m/Y H:i", 0x2d => "i:s", 0x2e => "H:i:s", 0x2f => "i:s.S" ); 

the following works with 2.21 too, i cheked before i post
hope that help

Original comment by fangbear...@gmail.com on 29 Oct 2014 at 2:42