DateTime conversion support
It should be possible to submit a date through a form via POST and receive a date time object as an argument in a controller. Hence we need a Type Converter supporting array to DateTime conversion. The input format should be configurable, unix timestamp would be a good default.
[FEATURE] DateTime conversion support
This adds a new Type Converter which is capable of converting dates
given as string into DateTime objects. The source can be either of
type string or array.
By default it expects the string in the format "Y-m-d\TH:i:sP"
(= DateTime::W3C) but this can be overridden via MappingConfiguration.
If source is an array, expected date format, time and timezone can
be overridden from the source as well:
Example for a Fluid form (snippet):
<f:form.hidden name="newPost[date][format]" value="d.m.Y - H:i:s" />
<input type="text" name="newPost[date][date]" id="date" /><br />
See #27417 for a more advanced sample.
#2 Updated by Bastian Waidelich almost 9 years ago
A few more notes after quickly discussing this with Sebastian:
- We probably shouldn't use Timestamp as default date format as its timezone dependent
- The default date should be an ISO date format that also contains the time
- The DateTimeConverter might also support an array that contains the format string
I'll take care of the above changes and push a version to gerrit (to the FLOW3 package) if no-one objects. @Robert if you already started working on this, let me know.
#7 Updated by Bastian Waidelich almost 9 years ago
- Subject changed from Basic DateTime conversion support to DateTime conversion support
With the new changeset I have just pushed, it is possible to override dateFormat, time and timezone on the client side:
<input type="hidden" name="newPost[date][dateFormat]" value="d.m.Y" /> <label for="date">Date (d.m.Y)</label> <input type="text" name="newPost[date][date]" id="date" /> <label for="hour">Time</label> <select name="newPost[date][hour]" id="hour"> <option value="1">01</option> [...] </select>: <select name="newPost[date][minute]" id="minute"> <option value="1">01</option> [...] </select> <label for="timezone">Timezone</label> <select name="newPost[date][timezone]" id="timezone"> <option value="Africa/Abidjan">Africa/Abidjan</option> [...] </select>