I am using WP All Import plugin for Wordpress and trying to import a date cell but I need it converting from a user friendly date to a unix timestamp.
23/04/2021 13:50
to
1606694400
WP All Import allows me to run a php function when importing into a custom field. I have found we can use the following within php:
strtotime()
I also found the below link to suggest a method of using inline php with the plugin but it's using a price example.
https://www.wpallimport.com/documentation/developers/custom-code/inline-php/
My column containing dates is called Date which the plugin would map data to using:
{date[1]}
My Answer:
To convert the date to a Unix timestamp using the strtotime() function in a PHP function during import with WP All Import, you can use the following code snippet:
php
$timestamp = strtotime({date[1]});
return $timestamp;
You can add this code snippet to the PHP function field in WP All Import when mapping the data to the custom field. This will convert the user-friendly date to a Unix timestamp during the import process.
Rate this post
4 of 5 based on 5742 votesComments