Update mysql from Excel

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
Lonestarjack
Forum Commoner
Posts: 31
Joined: Tue Nov 11, 2008 7:13 am
Location: Texas

Update mysql from Excel

Post by Lonestarjack »

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?
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Update mysql from Excel

Post by Jade »

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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Update mysql from Excel

Post by Christopher »

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)
Post Reply