tags:

views:

49

answers:

2

I am trying to prepare an Excel report using php. In the report I have a column called 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?

+4  A: 

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).

Zabba
@Zabba: How do we solve this .How do we corrrect this
Someone
My thoughts exactly
captaintokyo
@Someone - provide us with the extra information we've asked you for, and we might be able to help you resolve your problem
Mark Baker
You solve it via Excel settings.
hopeseekr
One way could be to write a macro that formats the required column in a specific date format. Of course you would need to put that macro into the Excel file and have it execute once (upon first opening of the file). Or maybe the component you are using for exporting to Excel has some options?
Zabba
+2  A: 

'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'.

RavenM