I have date
$timeZome = timezone_open('Europe/Kiev');
$date开发者_StackOverflow中文版 = new DateTime();
$date->setTimezone($timeZome);
$date->setDate(2011, 06,25);
$date->setTime(11,35,00);
How to present like that?
20110625T040000Z
This will do what you want:
$date = new DateTime();
$date->setTimezone(new DateTimeZone('Europe/Kiev'));
$date->setDate(2011, 06,25);
$date->setTime(11,35,00);
$date->setTimezone(new DateTimeZone('UTC'));
echo $date->format('Ymd\THis\Z'); // format string to match question
It's pretty straightforward: set the date/time/zone, modify the timezone and format for printing.
You may just need to call format on your date object, I think.
echo $date->format('Ymd'); // 20110625
UPDATE: You may want to look into either using the existing constants in the date class, or if your needs differ from what date offers, simply extend it and add a method that parses and returns your date formatted as you want it to.
精彩评论