Created
February 12, 2013 08:20
-
-
Save sivaprabug/4760944 to your computer and use it in GitHub Desktop.
Change the date format and store in DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$conn=mysql_connect("localhost","root","kirti123") ; | |
if(!$conn) | |
{ | |
die('connection Error' . mysql_error()); | |
} | |
// DATE CONVERSION | |
$date=$_POST['add_date']; // get the date value in post method | |
$date_array = explode("-",$date); // split the array | |
$var_month = $date_array[0]; //month segment | |
$var_day = $date_array[1]; //day seqment | |
$var_year = $date_array[2]; //year segment | |
$new_date_format = "$var_year-$var_month-$var_day"; // join them together | |
mysql_select_db('test',$conn); | |
$sqll="INSERT INTO register(name, nickname, mbno, add_date) VALUES ('$_POST[name]', '$_POST[nickname]', '$_POST[mbno]','$new_date_format')"; | |
if(!mysql_query($sqll,$conn)) | |
{ | |
die('Error in Connection' .mysql_error()); | |
} | |
echo "Added Successfully"; | |
mysql_close($conn) | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment