csv, convert date, mysql, php

Reply

Join Date: Dec 2007
Posts: 1
Reputation: budiman is an unknown quantity at this point 
Solved Threads: 0
budiman budiman is offline Offline
Newbie Poster

csv, convert date, mysql, php

 
0
  #1
Dec 17th, 2007
HI

I want to submit csv file data into mysql using php.
One of the fields contain data : date with format (dd-mm-yyy).
I want to store the data in mysql with date format (yyy-mm-dd).
pls tell me how 2 do.
pls help me
Thanks.
bye
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 1,602
Reputation: scru has a spectacular aura about scru has a spectacular aura about 
Solved Threads: 130
Featured Poster
scru's Avatar
scru scru is offline Offline
Posting Virtuoso

Re: csv, convert date, mysql, php

 
0
  #2
Dec 17th, 2007
First you calculate a timestamp integer from the old date (that is the number of seconds from January 1, 1970 00:00:00 GMT to the old date).

Then you call the php function date() with a format string and pass in the timestamp. Like so:
  1. $datestring = date("Y-m-d", $timestamp);

See here for more information on using date format strings.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,744
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 330
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: csv, convert date, mysql, php

 
0
  #3
Dec 17th, 2007
First, you fetch the data from the csv file using fgetcsv. Its returns the value as an array. Access the array element where the date is stored and do as scru has mentioned.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC