[wp-hackers] Saving DATETIME with $wpdb->insert ?

BenderisGreat greglancaster71 at gmail.com
Fri Jan 31 01:10:01 UTC 2014


Having an issue while saving datetime in the db.  Insert is a success with
the exception of the datetime field which remains as 0000-00-00 00:00:00. 
Not sure why, I am using wordpress' current_time('mysql', 1) format.  Also
tried date('Y-m-d h:i:s') without any success.  I feel stupid asking this,
but I really dont understand why this is failing. It saves properly if I use
%s but I read that datetime should not be saved as a string ever on
stackoverflow.  



    $sql2 = $wpdb->insert($activityTable, 
    		array(
    			  'user_id' => $profile_id,
    			  'activity_cat' => 'status',
    			  'type' => 'status_update',
    			  'action' => $actionUpdate,
    			  'content' => $statusUpdate,
    			  'time' => current_time('mysql', 1)
    		),
    		array(
    			  '%d',
    			  '%s',
    			  '%s',
    			  '%s',
    			  '%s',
    			  '%d'
    			  )
    		);




--
View this message in context: http://wordpress-hackers.1065353.n5.nabble.com/Saving-DATETIME-with-wpdb-insert-tp43278.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.


More information about the wp-hackers mailing list