Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format a datetime so that Excel will understand it?

I have a script which outputs a CSV file. How should I format dates or date+time fields so that Excel will correctly parse that field as a date?

PS: I'd like to keep timezone information intact as well.

like image 833
nickf Avatar asked May 10 '10 06:05

nickf


People also ask

How do I format datetime in Excel?

On the Home tab, in the Number group, click the Dialog Box Launcher next to Number. You can also press CTRL+1 to open the Format Cells dialog box. In the Category list, click Date or Time. In the Type list, click the date or time format that you want to use.

Does Excel Recognise date and time in any format?

Explanation: Dates and times with a format that begins with an asterisk (*) automatically update based on your PC's regional settings.

How do you fix datetime in Excel?

To change the date or time format, right-click on a cell, and select Format Cells. Then, on the Format Cells dialog box, in the Number tab, under Category, click Date or Time and in the Type list, select a type, and click OK.


1 Answers

Excel's date format does not contain any information about time zones. I would export the time zone as a separate column, perhaps as an offset from GMT, like 5 or -2. I personally prefer the unambiguous yyyy-mm-dd date format.

like image 74
dendarii Avatar answered Oct 04 '22 02:10

dendarii