Most of the times we would need to export or import today's date or a custom format date in our export and import operations. This can be now be easily accompolished using RO CSVI Multi replace rule plugin.
Date format on export
The example here explains on how to create a rule in Multi replace plugin for exporting today's date in your exports, the same can be followed for import too.
- Create a new Multi replace rule for export
- Select Operation as Date
- Under Filter section and Date format field enter the format you want to export date, for example like d-m-Y. Check for other date formats with PHP date documentation.
- Save the rule
- Apply the rule on your export template fields.
Running an export by setting Today's date export on custom template field, an example in export file will look like below
Date format on import
An example for import using date format for field created_on in VirtueMart Product import is explained below.
1. Create VirtueMart Product import template and add created_on as one of the field in import
2. This is the preview page before applying the date rule.
3. Now create a rule using Multi replace plugin with date as operation. Add a date format to the rule.
4. Apply the rule on created_on field
5. Run the import and check the preview page.
Custom date format
It is sometimes needed to change the date format you need to import or export from or to database. Custom date format operation in RO CSVI Multi replace plugin will help you with this. The below example explains changing date format for export, the same can be followed for import too.
Custom date format for export
- Create a new Multi replace rule for export
- Select Operation as Custom date format
- Under Filter section and Date format field enter the format you want to change the date to, for example like m.d.y
- Save the rule
- Apply the rule on your export template fields.
The default date format stored in database is Y-m-d H:i:s where Y is the year, m is the month, d is the date, H is the hour, i is the minutes and s is the seconds. You can change this default format to any needed custom format in your export and in import you can change the date format in your import file to database supported format. Check for other date formats with PHP date documentation.
An example export file created by applying Custom date format rule on created_on field in VirtueMart product export is shown below
Custom date format for import
Here in this example we are explaining about using custom date format to change the format of created_on date on VirtueMart product import to database supported format Y-m-d H:i:s.
1. Create a rule using Multi replace plugin
2. Create VirtueMart Product import template and add created_on as a template field. Apply custom date rule on created_on field.
3. Run the import and check the preview page.