Jump to content

Recommended Posts

suppose $arr7 contains this value '10/5/2007 6:02' how can i format that to be change like this '2007-01-22 08:55:19' when im going to use it in a insert statement here's the code

 

$sql = "INSERT INTO Links(URL,Title,Description,Email,SubmitURL,ContactedOn)

VALUES('{$arr[0]}','{$arr[1]}','{$arr[2]}','{$arr[3]}','{$arr[4]}','{$arr[7]}')"

 

original value format = 10/5/2007 6:02

target value format before storing to sql = 2007-01-22 08:55:19

 

 

Link to comment
https://forums.phpfreaks.com/topic/72718-help-with-php-sql-insert-statement/
Share on other sites

 

$new_val=strtotime($arr[7]);

$into_db=date("Y-m-d H:i:s",$new_val);

 

//or $into_db=date("Y-d-m H:i:s",$new_val); depending on whether $arr[7] is America(mm/dd/yyyy) or English date format(dd/mm/yyyy)

 

$sql = "INSERT INTO Links(URL,Title,Description,Email,SubmitURL,ContactedOn)

      VALUES('{$arr[0]}','{$arr[1]}','{$arr[2]}','{$arr[3]}','{$arr[4]}','$into_db"

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.