Troubleshooting //
How to Fix the 1970-01-01 Date Field in the Post

How to Fix the 1970-01-01 Date Field in the Post


When I create the Post by the JetEngine Forms, the Date Field is 1970-01-01


Check the CPT fields

Go to JetEngine > Post Types and open to edit the CPT that you need. Scroll down to the Date meta field, open it and see if the Name/ID is set properly. The field should contain neither uppercase letters nor spaces. Also, check if the Save as timestamp option is enabled and enable it if necessary.

date meta field settings

Check the Form settings

Open the Forms tab in the JetEngine WordPress submenu. Open the needed form through which you add the post with the date – New Post, for example – and find the Date type field in the Fields Settings list. Press the pencil icon to edit the field. Make sure to tick the Is Timestamp checkbox and save the changes.

active is timestamp option in the date field settings

Next, proceed to the Post-Submit Actions / Notification Settings section. There, you should set the Insert/Update Post notification type. Click the pencil icon to edit it and see if all settings are set properly. 

Press the “Apply Changes” button and update the Form.

Add the code to the functions.php file

Go to Appearance > Theme Editor and press the Theme Functions (functions.php) tab in the right-side section. 

functions.php editing window

Next, scroll the content down and paste the following code to the functions.php file:

add_action( 'jet-engine/forms/booking/notification/insert_post', function( $notification, $manager ) {
   if ( ! empty( $manager->data['_date_field'] ) ) {
      $manager->data['_date_field'] = strtotime( $manager->data['_date_field'] );
}, 0, 2 );

Where the ‘_date_field’ value should be the name of your Date field in the form. 

form field date name

Please make sure to doublecheck it and substitute the default value with your own wherever necessary. Once done, press to update the file.

functions.php code input

Try to create a new post

Open the page where the form is placed on the frontend and try to submit a new post. Fill out all the required fields including the date and send the form. 

submitting a frontend form

Then proceed to WP dashboard, find the needed custom post type and its posts, and open the post you’ve just submitted. Scroll down to the Date meta field and there you have it! The date that you added in the frontend form appeared here as expected.

checking the date meta field content

Was this article helpful?
Still need help?
Submit a request