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

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:

$datestring = date("Y-m-d", $timestamp);

See here for more information on using date format strings.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.