hii,
i've 5 columns in my excel sheet,
SNO Name Age Date Province
i gave today's date under the "date" column field as "12/3/2008"(choosen first format for date in my excel sheet)
when i read the excel sheet using php excel reader class, then the date is being displayed as,
"04/12/2008".
can anyone please help me,, why is this happening..?
many regards.
php date not working
Moderator: General Moderators
- pavanpuligandla
- Forum Contributor
- Posts: 130
- Joined: Thu Feb 07, 2008 8:25 am
- Location: Hyderabad, India
Re: php date not working
Month/Day/Year is the United States way of stating the date, Day/Month/Year is everyone else.
Is it really adding a day like your example shows, or is it just reversing the month & day order?
Is it really adding a day like your example shows, or is it just reversing the month & day order?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: php date not working
Are you actually storing the date as an Excel date, or as a string?pavanpuligandla wrote:i gave today's date under the "date" column field as "12/3/2008"(choosen first format for date in my excel sheet)
when i read the excel sheet using php excel reader class, then the date is being displayed as,
"04/12/2008".
- pavanpuligandla
- Forum Contributor
- Posts: 130
- Joined: Thu Feb 07, 2008 8:25 am
- Location: Hyderabad, India
Re: php date not working
yeah i'm storing it as excel date..Are you actually storing the date as an Excel date, or as a string?
in php reader class,
the date formats are like the listed below;
there is no american M_DD_YYYY format..
Code: Select all
var $dateFormats = array (
0xe => "d/m/Y",
0xf => "d-M-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");there's no problem with database insertions..
the problem is with php reader..
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: php date not working
If you can read the date as the numeric Excel timestamp, the following should allow you to convert it to a PHP timestamp:pavanpuligandla wrote:yeah i'm storing it as excel date..Are you actually storing the date as an Excel date, or as a string?
in php reader class,
the problem is with php reader..
Code: Select all
function ExcelToPHP($dateValue = 0) {
if ($ExcelBaseDate == CALENDAR_WINDOWS_1900) {
$myExcelBaseDate = 25569;
// Adjust for the spurious 29-Feb-1900 (Day 60)
if ($dateValue < 60) {
--$myExcelBaseDate;
}
} else {
$myExcelBaseDate = 24107;
}
// Perform conversion
if ($dateValue >= 1) {
$utcDays = $dateValue - $myExcelBaseDate;
$returnValue = (integer) round($utcDays * 24 * 60 * 60);
} else {
$hours = round($dateValue * 24);
$mins = round($dateValue * 24 * 60) - round($hours * 60);
$secs = round($dateValue * 24 * 60 * 60) - round($hours * 60 * 60) - round($mins * 60);
$returnValue = (integer) mktime($hours, $mins, $secs);
}
// Return
return $returnValue;
} // function ExcelToPHP()