[Flow] DateTime: How can i save only the Date without the time in the db?
Timo Poppinga
poppinga at iljansoft.de
Tue Jan 21 17:14:36 CET 2014
Hi Martin,
thx for your inspiration.
I solve it by changing the setter like this:
/**
* @param \DateTime
* @return void
*/
public function setMediaDate($mediaDate) {
$dateString = $mediaDate->format('Y-m-d');
$this->mediaDate = new \DateTime($dateString);
}
BG
Timo
iljansoft
Timo Poppinga
Mobile: +49 175 2 40 50 90
Inhaber: Timo Poppinga · Voßheider Str. 263 · 47574 Goch · E-Mail: poppinga at iljansoft.de · www.iljansoft.de
USt-IdNr.: DE 261656040
Am 16.01.2014 um 20:17 schrieb Martin Keck <keck at bloomproject.de>:
> Hi Timo,
>
> as an untested approach you may convert the given datetime string to an array setting hour, minute and seconds to 0 before handing it over to the propertyMapper.
> Could look like this:
>
> $dateAr = explode('.', $mediaDate);
> $dateAr = array(
> 'day' => $dateAr[0],
> 'month' => $dateAr[1],
> 'year' => $dateAr[2],
> 'hour' => 0,
> 'minute' => 0,
> 'seconds' => 0);
>
> See here for handing over an array to the propertyMapper:
> http://docs.typo3.org/flow/TYPO3FlowDocumentation/TheDefinitiveGuide/PartV/TypeConverterReference.html#datetimeconverter
>
>
> Regards
> Martin
>
>
>
>
> Am 16.01.2014 um 15:59 schrieb Timo Poppinga <poppinga at iljansoft.de>:
>
>> Hi Christian,
>>
>> this was an copy paste mistake.
>>
>> So this will not solve the problem.
>>
>> But thx a lot for the hint
>>
>> Timo
>>
>>
>> iljansoft
>> Timo Poppinga
>> Mobile: +49 175 2 40 50 90
>>
>> Inhaber: Timo Poppinga · Voßheider Str. 263 · 47574 Goch · E-Mail: poppinga at iljansoft.de · www.iljansoft.de
>> USt-IdNr.: DE 261656040
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Am 16.01.2014 um 15:13 schrieb Christian Huppert <chr.huppert at yahoo.de>:
>>
>>> Hi Timo,
>>>
>>> I am quite new to Typo3 Flow, so I am not sure if my message is helpful but I saw that you forgot to close the d.m.Y with a single quote.
>>> Maybe this already sorts out your issue.
>>>
>>> Best
>>> Christian
>>>
>>>
>>>
>>>
>>> Timo Poppinga <poppinga at iljansoft.de> schrieb am 14:31 Donnerstag, 16.Januar 2014:
>>>
>>> Hi,
>>>
>>> how can i save only the Date without the time in the db?
>>>
>>> I Format the field like this
>>> $propertyMappingConfiguration->forProperty('mediaDate')
>>> ->setTypeConverterOption(
>>> 'TYPO3\Flow\Property\TypeConverter\DateTimeConverter',
>>> \TYPO3\Flow\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT,
>>> 'd.m.Y
>>> );
>>>
>>>
>>> but now the system save the correct date plus the current time this triggers issues making an db query.
>>>
>>> I like that only the date is saved in the db or 2014-01-16 00:00 is also ok.
>>>
>>> Thx
>>>
>>> Timo
>>>
>>> iljansoft
>>> Timo Poppinga
>>> Mobile: +49 175 2 40 50 90
>>>
>>> Inhaber: Timo Poppinga · Voßheider Str. 263 · 47574 Goch · E-Mail: poppinga at iljansoft.de · www.iljansoft.de
>>> USt-IdNr.: DE 261656040
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Flow mailing list
>>> Flow at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>>> _______________________________________________
>>> Flow mailing list
>>> Flow at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>>
>> _______________________________________________
>> Flow mailing list
>> Flow at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>
>
>
> Bloom ist Branchensieger im „Jahr der Werbung" 2013. In der Kategorie
> „Alkoholische Getränke“ (B2C) landete Bloom auf dem ersten Platz. Alle Infos
> auf http://www.bloomproject.de/arbeiten/show/lederer-markenpositionierung/
>
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
More information about the Flow
mailing list