Reading a date #3115
-
Good morning, How can I systematically get a date? Thanks for your answer |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I can see that I'm going to have to rewrite the documentation to be very explicit about how dates work in MS Excel; and explain how to read dates as well as write them. This article explains in more detail about dates in MS Excel. TLDR: MS Excel maintains dates as a serialized timestamp, a numeric value that represents the number of days since a base start date of 1/1/1900 (or 1/1/1904 if the file was created using the Apple Mac version of Microsoft Office). This is similar to a unix timestamp, a numeric value representing a date. If you get a value of "23/03/1970", then you're getting a string; just because it looks like a date to a human, it's still a string. if you're getting a value of 25940, that could be a date, or simply a number. The only difference between a date and a number is the number format mask. If you know that a cell should contain a date, then the Cell's The PhpSpreadsheet also provides a method to determine if a cell value is a number or a date PhpOffice\PhpSpreadsheet\Shared\Date::isDateTime($worksheet->getCell('A1')); |
Beta Was this translation helpful? Give feedback.
-
Thanks, |
Beta Was this translation helpful? Give feedback.
I can see that I'm going to have to rewrite the documentation to be very explicit about how dates work in MS Excel; and explain how to read dates as well as write them. This article explains in more detail about dates in MS Excel.
TLDR: MS Excel maintains dates as a serialized timestamp, a numeric value that represents the number of days since a base start date of 1/1/1900 (or 1/1/1904 if the file was created using the Apple Mac version of Microsoft Office). This is similar to a unix timestamp, a numeric value representing a date.
If you get a value of "23/03/1970", then you're getting a string; just because it looks like a date to a human, it's still a string. if you're getting a value o…