Why the date is Displayed different from excel to browser
I am trying to prepare an Excel report using php. In the report I have a column called 开发者_C百科date. I am trying to format the date as date('d-M-Y',strtotime($row['MYDATE']));
.
So my problem is when displayed on the browser it is displaying in correct format (10-SEP-2010)
but when on the excel sheet it is displaying as follows (9/10/2010)
.
Why would there be difference and how do I resolve this?
Possibly because in the PHP code you are explicitly specifying the format to use, so it appears in the browser as expected (a date value has been converted into a "string").
In Excel, the date string is being auto-detected and being formatted according to the systme's Regional settings (which seems to be set to US on the target system).
'd-M-y' will not give you the format you want in Excel. You will need to explicitly format the Excel cell with the format code 'dd-MMM-YYYY'.
精彩评论