本文整理汇总了PHP中JevDate::toMySQL方法的典型用法代码示例。如果您正苦于以下问题:PHP JevDate::toMySQL方法的具体用法?PHP JevDate::toMySQL怎么用?PHP JevDate::toMySQL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JevDate
的用法示例。
在下文中一共展示了JevDate::toMySQL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unixTime
/**
* iCal spec represents date in ISO 8601 format followed by "T" then the time
* a "Z at the end means the time is UTC and not local time zone
*
* TODO make sure if time is UTC we take account of system time offset properly
*
*/
function unixTime($ical_date, $tz = false)
{
jimport("joomla.utilities.date");
static $offset = null;
if (is_null($offset)) {
$config =& JFactory::getConfig();
$offset = $config->getValue('config.offset', 0);
}
if (!is_numeric($ical_date)) {
$t = JevDate::strtotime($ical_date);
if (JString::strpos($ical_date, "Z") > 0) {
if (is_callable("date_default_timezone_set")) {
$timezone = date_default_timezone_get();
// See http://www.php.net/manual/en/timezones.php
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
// server offset tiemzone
if ($params->get("icaltimezone", "") != "") {
date_default_timezone_set($params->get("icaltimezone", ""));
}
// server offset PARAMS
$serveroffset1 = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600;
// server offset SERVER
date_default_timezone_set($timezone);
$serveroffset2 = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600;
$t = new JevDate($ical_date, $serveroffset1 - $serveroffset2);
//$t = new JevDate($ical_date );
date_default_timezone_set($timezone);
echo "icaldate = " . $ical_date . " imported date=" . $t->toMySQL() . "<br/>";
} else {
// Summer Time adjustment
list($y, $m, $d, $h, $min, $s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S', $t));
$dst = (JevDate::mktime($h, $min, $s, $m, $d, $y, 0) - JevDate::mktime($h, $min, $s, $m, $d, $y, -1)) / 3600;
// server offset including DST
$serveroffset = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600;
$serveroffset += $dst;
$t = new JevDate($ical_date, -($serveroffset + $offset));
}
/*
echo "<h3>SET TIMEZONE</h3>";
$timezone= date_default_timezone_get();
date_default_timezone_set('America/New_York');
$tempIcal = "20091020T163000Z";
echo $tempIcal."<br/>";
$temp = JevDate::strtotime($tempIcal);
list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp));
echo "$y,$m,$d,$h,$min,$s<br/>";
$dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600;
$so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600;
echo " dst=".$dst." serverforoffset=".$so."<br/>";
$so += $dst;
$t = new JevDate($tempIcal);
echo $t->toMySQL()."<br><br/>";
$tempIcal = "20091029T163000Z";
echo $tempIcal."<br/>";
$temp = JevDate::strtotime($tempIcal);
list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp));
echo "$y,$m,$d,$h,$min,$s<br/>";
$dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600;
$so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600;
echo " dst=".$dst." serverforoffset=".$so."<br/>";
$so += $dst;
$t = new JevDate($tempIcal );
echo $t->toMySQL()."<br><br/>";
$tempIcal = "20091103T163000Z";
echo $tempIcal."<br/>";
$temp = JevDate::strtotime($tempIcal);
list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp));
echo "$y,$m,$d,$h,$min,$s<br/>";
$dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600;
$so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600;
echo " dst=".$dst." serverforoffset=".$so."<br/>";
$so += $dst;
$t = new JevDate($tempIcal);
echo $t->toMySQL()."<br>";
*/
} else {
if ($tz != false && $tz != "") {
// really should use the timezone of the inputted date
$tz = new DateTimeZone($tz);
$t = new JevDate($ical_date, $tz);
echo "icaldate = " . $ical_date . " imported date=" . $t->toMySQL() . "<br/>";
} else {
$compparams = JComponentHelper::getParams(JEV_COM_COMPONENT);
$jtz = $compparams->get("icaltimezonelive", "");
if ($jtz) {
$t = new JevDate($ical_date, $jtz);
} else {
$t = new JevDate($ical_date);
}
//.........这里部分代码省略.........