I have an Excel file with a date column that looks like this -- 6/13/2011 9:43:24 PM.
I can use Excel_reader to conver the Excel file into an array and then extract the date field.
I want to use getDate to extract information like day of the week etc before posting to a mysql file.
I have tried many different ways, but can't seem to get the correct commands to be able to use the getDate function.
Is this possible?
Update mysql from Excel
Moderator: General Moderators
- Lonestarjack
- Forum Commoner
- Posts: 31
- Joined: Tue Nov 11, 2008 7:13 am
- Location: Texas
Re: Update mysql from Excel
You need to pass getDate a timestamp, not a formatted date. That means you'll need to use strtotime on the date before you pass it to getDate.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Update mysql from Excel
Use strtotime() to get a timestamp first. Then you can get the parts of the date/time. You also might want to use the DateTime class.
(#10850)