[TYPO3-german] Kampf zwischen DateTime-Object und strftime()
Christian Wolff
chris at connye.com
Wed Sep 28 12:02:14 CEST 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 28.09.2011 11:49, schrieb Stefan Frömken:
> Hallo zusammen,
>
> ich habe folgendes kleines Script:
>
> <?php $date = new DateTime('@1315173600'); echo "Datum DateTime:" .
> $date->format('d.m.Y H:i:s'); echo "<br />"; echo "Datum strftime:"
> . strftime('%d.%m.%Y - %T', 1315173600); ?>
>
> Die Ausgabe:
>
> Datum DateTime:04.09.2011 22:00:00 Datum strftime:05.09.2011 -
> 00:00:00
>
> Irgendjemand einen Tipp für mich wie ich das Problem lösen kann?
> Richtig ist der Wert aus strftime.
>
> Das Problem ist erst mit dem Wechsel von piBase auf Fluid
> aufgetreten, denn innerhalb von Fluid arbeitet f:format.date ja mit
> DateTime und nicht mit strftime.
>
> Ich brauch irgendeine Lösung, um die Werte synchron zu bekommen.
> Jemand eine Idee?
>
> Stefan
Hi Stefan,
das DateTime Projekt ignoriert die timezone fals ein unixtimestamp
übergeben wird:
aus der php doku:
"The $timezone parameter and the current timezone are ignored when the
$time parameter either is a UNIX timestamp (e.g. @946684800) or
specifies a timezone (e.g. 2010-01-28T15:00:00+02:00). "
http://de.php.net/manual/de/datetime.construct.php
und interpretieren diesen dann offensichtlich als GMT 0 du könntest
vieleicht einfach noch mal die zeitzone setzten: DateTime::setTimezone
strftime nimmt den timstamp auch als GMT 0 formatiert ihn aber
entsprechend den lokalen einstellungen GMT +2
gruss chris
- --
Christian Wolff // Berlin
http://www.connye.com
some projects:
http://richtermediagroup.com | http://titanic.de | http://keyopinions.info
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
iEYEARECAAYFAk6C8KUACgkQIcCaXPh/JHG1YgCfTMqM6VXdYSgwnJNyl80DJ+/h
yRoAoJIFpXH54FqCVV7J6FVwjU8Swx2i
=L5MZ
-----END PGP SIGNATURE-----
More information about the TYPO3-german
mailing list