Problem/Motivation
There are some date formats that can not be easily resolved with strtotime().
It'd be useful if the user could specify the custom format the date is in so that it can be parsed consistently.
Steps to reproduce
Attempt to convert the date 30/06/2025 23:59:00 into time, it should ideally be parsed as mm/dd/yyyy format, but there's no easy way to parse that currently, except doing a somewhat hacky search and replace of the "/" with "-".
Proposed resolution
It'd be better if the plugin builder can specify the expected format of the date so that certain date formats can be easily converted to a date.
Remaining tasks
Provide issue fork/patch.
User interface changes
There should be a new "Custom date format" option on the plugin page. If it's not set, the previous strtotime() behaviour will be kept.
API changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3530530.png | 227.04 KB | megachriz |
Issue fork tamper-3530530
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
codebymikey commentedComment #4
codebymikey commentedComment #5
megachrizThis is a great addition! I do wonder if we should fallback to
strtotime()when parsing the date fails. Maybe provide that as an option? "Fallback tostrtotime()if the date could not be parsed.". What do you think?If you have applied the Tamper "String to Unix Timestamp" to the source "content" and set the date format to "d/m/Y" and then import the following CSV:
This is the result after import (using the latest dev releases of Feeds and Feeds Tamper):

Comment #6
megachrizI've added the fallback option. 🙂
Comment #7
codebymikey commentedThe fallback option seems useful, the more flexibility the better.
I'd still personally recommend that users avoid using
strtotime()blindly since as per the original issue, it can accidentally convert it into the wrong date, so your feed should ideally have a standardized format to convert from (however having the fallback option still wouldn't hurt for cases where the dates are entered manually).All that being said, the code and tests looks good! RTBC.
Comment #9
megachrizThanks for the review! I merged the code.