本文整理汇总了PHP中XMLElement::getTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLElement::getTimestamp方法的具体用法?PHP XMLElement::getTimestamp怎么用?PHP XMLElement::getTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLElement
的用法示例。
在下文中一共展示了XMLElement::getTimestamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: appendFormattedElement
public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
{
$datetime = new XMLElement($this->get('element_name'));
// Prepare data
if (!is_array($data['start'])) {
$data['start'] = array($data['start']);
}
if (!is_array($data['end'])) {
$data['end'] = array($data['end']);
}
// Get timeline
$timeline = $data['start'];
sort($timeline);
// Generate XML
foreach ($data['start'] as $id => $date) {
$date = new XMLElement('date');
$date->setAttribute('timeline', array_search($data['start'][$id], $timeline) + 1);
// Start date
$start = new DateTime($data['start'][$id]);
$date->appendChild($start = new XMLElement('start', $start->format('Y-m-d'), array('iso' => $start->format('c'), 'timestamp' => $start->getTimestamp(), 'time' => $start->format('H:i'), 'weekday' => $start->format('N'), 'offset' => $start->format('O'))));
// Date range
if ($data['end'][$id] != $data['start'][$id]) {
$end = new DateTime($data['end'][$id]);
$date->appendChild($end = new XMLElement('end', $end->format('Y-m-d'), array('iso' => $end->format('c'), 'timestamp' => $end->getTimestamp(), 'time' => $end->format('H:i'), 'weekday' => $end->format('N'), 'offset' => $end->format('O'))));
$date->setAttribute('type', 'range');
} else {
$date->setAttribute('type', 'exact');
}
$datetime->appendChild($date);
}
// append date and time to data source
if (!empty($data['start'][0])) {
$wrapper->appendChild($datetime);
}
}