I can confirm that it is still happening. The time is UTC, not the local time (date.timezone =”country/place” PHP config).
Slightly difficult solution:
My preference would be for the submit_time to stay as UTC but for the data presentation (exports, admin forms) to show the DateTime in the defined timezone. Additionally the logic would be applied to all the SQL used.
Trivial solution:
Save the data in the local timezone.
DIY solution:
Use the vsz_cf7_posted_data filter:
function example_cf7_modify_form_before_insert_data( $posted_data ) {
$timestamp = WPCF7_Submission::get_instance()->get_meta( 'timestamp' );
if ( $timestamp ) {
$date = ( new DateTime( '', new DateTimezone( wp_timezone_string() ) ) )->setTimestamp( $timestamp );
$posted_data['submit_time'] = $date->format( 'Y-m-d H:i:s' );
}
return $posted_data;
}
-
This reply was modified 3 years, 10 months ago by adriangreen. Reason: remove hard-coded timezone string