本文整理汇总了PHP中Date::setDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::setDate方法的具体用法?PHP Date::setDate怎么用?PHP Date::setDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date::setDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDate
function setDate($date, $format = DATE_FORMAT_ISO)
{
if (is_numeric($date)) {
$this->setDate(gmdate("Y-m-d H:i:s", $date));
} else {
parent::setDate($date, $format);
}
}
示例2: testFromString
public function testFromString()
{
$expected = new Date();
$expected->setDate(2009, 11, 4);
$expected->setTime(01, 02, 03);
$this->assertEquals($expected->format('U'), Date::create('2009-11-04 01:02:03')->format('U'));
$this->assertEquals($expected->format('U'), Date::create('1257274923')->format('U'));
$this->assertEquals($expected->format('U'), Date::create(Date::create('1257274923'))->format('U'));
$this->assertEquals($expected->format('U'), Date::create(new DateTime('2009-11-04 01:02:03'))->format('U'));
$this->assertEquals($expected->format('U'), Date::create(new Date('2009-11-04 01:02:03'))->format('U'));
$expected->setTime(0, 0, 0);
$this->assertEquals($expected->format('U'), Date::create('2009-11-04 00:00:00')->format('U'));
$this->assertEquals($expected->format('U'), Date::create('2009-11-04')->format('U'));
$this->assertEquals($expected->format('U'), Date::create('1257271200')->format('U'));
$this->assertEquals($expected->format('U'), Date::create(Date::create('1257271200'))->format('U'));
$this->assertEquals($expected->format('U'), Date::create(new DateTime('2009-11-04'))->format('U'));
$this->assertEquals($expected->format('U'), Date::create(new Date('2009-11-04'))->format('U'));
}
示例3: manageCampaigns
//.........这里部分代码省略.........
if ($disableReason) {
// One of the campaign targets was exceeded, so disable
$message = '- Exceeded a campaign quota: Deactivating campaign ID ' . "{$aCampaign['campaign_id']}: {$aCampaign['campaign_name']}";
OA::debug($message, PEAR_LOG_INFO);
$report .= $message . "\n";
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignid = $aCampaign['campaign_id'];
$doCampaigns->find();
$doCampaigns->fetch();
$doCampaigns->status = OA_ENTITY_STATUS_EXPIRED;
$result = $doCampaigns->update();
if ($result == false) {
return MAX::raiseError($rows, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
}
phpAds_userlogSetUser(phpAds_userMaintenance);
phpAds_userlogAdd(phpAds_actionDeactiveCampaign, $aCampaign['campaign_id']);
} else {
// The campaign didn't have a diable reason,
// it *might* possibly be diabled "soon"...
$canExpireSoon = true;
}
}
}
// Does the campaign need to be disabled due to the date?
if ($aCampaign['end'] != OA_Dal::noDateValue()) {
// The campaign has a valid end date, stored in the timezone of the advertiser;
// create an end date in the advertiser's timezone, set the time, and then
// convert to UTC so that it can be compared with the MSE run time, which is
// in UTC
$aAdvertiserPrefs = OA_Preferences::loadAccountPreferences($aCampaign['advertiser_account_id'], true);
$oTimezone = new Date_Timezone($aAdvertiserPrefs['timezone']);
$oEndDate = new Date();
$oEndDate->convertTZ($oTimezone);
$oEndDate->setDate($aCampaign['end'] . ' 23:59:59');
// Campaigns end at the end of the day
$oEndDate->toUTC();
if ($oDate->after($oEndDate)) {
// The end date has been passed; disable the campaign
$disableReason |= OX_CAMPAIGN_DISABLED_DATE;
$message = "- Passed campaign end time of '{$aCampaign['end']} 23:59:59 {$aAdvertiserPrefs['timezone']} (" . $oEndDate->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEndDate->tz->getShortName() . ")': Deactivating campaign ID {$aCampaign['campaign_id']}: {$aCampaign['campaign_name']}";
OA::debug($message, PEAR_LOG_INFO);
$report .= $message . "\n";
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignid = $aCampaign['campaign_id'];
$doCampaigns->find();
$doCampaigns->fetch();
$doCampaigns->status = OA_ENTITY_STATUS_EXPIRED;
$result = $doCampaigns->update();
if ($result == false) {
return MAX::raiseError($rows, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
}
phpAds_userlogSetUser(phpAds_userMaintenance);
phpAds_userlogAdd(phpAds_actionDeactiveCampaign, $aCampaign['campaign_id']);
} else {
// The campaign wasn't disabled based on the end
// date, to it *might* possibly be disabled "soon"...
$canExpireSoon = true;
}
}
if ($disableReason) {
// The campaign was disabled, so send the appropriate
// message to the campaign's contact
$query = "\n SELECT\n bannerid AS advertisement_id,\n description AS description,\n alt AS alt,\n url AS url\n FROM\n " . $this->oDbh->quoteIdentifier($aConf['table']['prefix'] . $aConf['table']['banners'], true) . "\n WHERE\n campaignid = {$aCampaign['campaign_id']}";
OA::debug("- Getting the advertisements for campaign ID {$aCampaign['campaign_id']}", PEAR_LOG_DEBUG);
$rsResultAdvertisement = $this->oDbh->query($query);
if (PEAR::isError($rsResultAdvertisement)) {
示例4: date
// Reset period
$period_preset = '';
// Always refresh howLong and hour
$howLong = MAX_getValue('howLong', 'd');
$hour = MAX_getValue('hour');
} else {
$period_preset = MAX_getStoredValue('period_preset', 'today');
$period_start = MAX_getStoredValue('period_start', date('Y-m-d'));
$period_end = MAX_getStoredValue('period_end', date('Y-m-d'));
}
if (!empty($period_preset)) {
$aDates = MAX_getDatesByPeriod($period_preset, $period_start, $period_end);
} else {
$aDates = array();
$oDayDate = new Date();
$oDayDate->setDate($day, DATE_FORMAT_TIMESTAMP);
if (!empty($hour)) {
// If hour is set build day date including hour
$aDates['day_hour'] = $oDayDate->format('%Y-%m-%d') . ' ' . $hour;
} else {
// Build month, day, day_begin and day_end dependends on $howLong
switch ($howLong) {
case 'm':
$aDates['month'] = $oDayDate->format('%Y-%m');
break;
case 'w':
$aDates['day_begin'] = $oDayDate->format('%Y-%m-%d');
$oDayDate->addSeconds(60 * 60 * 24 * 7);
// Add 7 days
$aDates['day_end'] = $oDayDate->format('%Y-%m-%d');
break;
示例5: DaysNameofMonth
function DaysNameofMonth($Month, $Year)
{
$date = new Date();
$Date_Calc = new Date_Calc();
$date->setYear($Year);
$date->setMonth($Month);
$NodaysMonth = $date->getDaysInMonth();
$firstDate = $Year . "-" . $Month . "-01";
$date->setDate($firstDate);
$daysName = array();
for ($i = 0; $i < $NodaysMonth; $i++) {
$daysName[$i] = $date->getDayName(True, 3);
$getNextday = $date->getNextDay();
$date->setDate($getNextday);
}
return $daysName;
}
示例6: setValueFromArray
/**
* A method to set the value of the field using the input querystring fields passed in from the HTML.
*
* @param array $aQuerystring The querystring of this field.
*/
function setValueFromArray($aFieldValues)
{
$fieldSelectionName = $aFieldValues[$this->_name . '_preset'];
if (!empty($fieldSelectionName)) {
if ($fieldSelectionName == 'specific') {
$oDaySpan = new OA_Admin_DaySpan();
$sStartDate = $aFieldValues[$this->_name . '_start'];
$oStartDate = new Date();
if ($sStartDate == '') {
$sStartDate = '1995-01-01';
}
$oStartDate->setDate($sStartDate);
$sEndDate = $aFieldValues[$this->_name . '_end'];
$oEndDate = new Date();
if ($sEndDate != '') {
$oEndDate->setDate($sEndDate);
}
$oDaySpan->setSpanDays($oStartDate, $oEndDate);
} elseif ($fieldSelectionName == 'all_stats') {
$oDaySpan = null;
} else {
$oDaySpan = new OA_Admin_DaySpan($fieldSelectionName);
}
$this->_value = $oDaySpan;
$this->_fieldSelectionValue = $fieldSelectionName;
}
}
示例7: nextDay
public function nextDay()
{
$timestamp = $this->getTimestamp() + 86400;
$nextDay = new Date();
$nextDay->setDate(date("Y", $timestamp), date("m", $timestamp), date("d", $timestamp));
$nextDay->setTime(date("G", $timestamp), date("i", $timestamp), date("s", $timestamp));
return $nextDay;
}
示例8: getPrevWeekday
/**
* Get a Date object for the weekday before this one
*
* Get a Date object for the weekday before this one.
* The time of the returned Date object is the same as this time.
*
* @access public
* @return object Date Date representing the previous weekday
*/
function getPrevWeekday()
{
$day = Date_Calc::prevWeekday($this->day, $this->month, $this->year, "%Y-%m-%d");
$date = sprintf("%s %02d:%02d:%02d", $day, $this->hour, $this->minute, $this->second);
$newDate = new Date();
$newDate->setDate($date);
return $newDate;
}
示例9: Date
$datetest->addSeconds(1043539200, true);
compare("26/07/2005 05.29.36.98765", $datetest->formatLikeSQL("DD/MM/YYYY HH.MI.SS.FFFFF"), "1043539200");
$datetest = new Date($date);
$datetest->addSeconds(1075161600, true);
compare("27/07/2006 05.29.35.98765", $datetest->formatLikeSQL("DD/MM/YYYY HH.MI.SS.FFFFF"), "1075161600");
// 23rd leap second in Dec 2005
$datetest = new Date($date);
$datetest->addSeconds(1106784000, true);
compare("28/07/2007 05.29.35.98765", $datetest->formatLikeSQL("DD/MM/YYYY HH.MI.SS.FFFFF"), "1106784000");
$datetest = new Date($date);
$datetest->addSeconds(1138406400, true);
compare("28/07/2008 05.29.35.98765", $datetest->formatLikeSQL("DD/MM/YYYY HH.MI.SS.FFFFF"), "1138406400");
$datetest = new Date($date);
$datetest->addSeconds(1170028800, true);
compare("29/07/2009 05.29.35.98765", $datetest->formatLikeSQL("DD/MM/YYYY HH.MI.SS.FFFFF"), "1170028800");
$date->setDate("2006-01-01 05:30:05.987654");
$datetest = new Date($date);
$datetest->addSeconds(-1, true);
compare("01/01/2006 05.30.04.98765", $datetest->formatLikeSQL("DD/MM/YYYY HH.MI.SS.FFFFF"), "-1");
$datetest = new Date($date);
$datetest->addSeconds(-2, true);
compare("01/01/2006 05.30.03.98765", $datetest->formatLikeSQL("DD/MM/YYYY HH.MI.SS.FFFFF"), "-2");
$datetest = new Date($date);
$datetest->addSeconds(-3, true);
compare("01/01/2006 05.30.02.98765", $datetest->formatLikeSQL("DD/MM/YYYY HH.MI.SS.FFFFF"), "-3");
$datetest = new Date($date);
$datetest->addSeconds(-4, true);
compare("01/01/2006 05.30.01.98765", $datetest->formatLikeSQL("DD/MM/YYYY HH.MI.SS.FFFFF"), "-4");
$datetest = new Date($date);
$datetest->addSeconds(-5, true);
compare("01/01/2006 05.30.00.98765", $datetest->formatLikeSQL("DD/MM/YYYY HH.MI.SS.FFFFF"), "-5");
示例10: getTemplateArrayCalendar
function getTemplateArrayCalendar($o_minDay, $s_date, $period)
{
// today
$today = new Date(getDateFromTimestamp(time()));
$tsToday = $today->getTimestamp();
// date asked for statistics
$dateAsked = new Date($s_date);
// used for going througt the month
$date = new Date($s_date);
$month = $date->getMonth();
$year = $date->getYear();
$prefixDay = $year . "-" . $month . "-";
$date->setDate($prefixDay . '01');
$week = $date->getWeek();
$day = 1;
$ts = $date->getTimestamp();
while ($date->getMonth() == $month) {
// day exists in stats, isn't it too old or in the future ?
if ($date->getTimestamp() >= $o_minDay->getTimestamp() && $date->getTimestamp() <= $tsToday) {
$exists = 1;
} else {
$exists = 0;
}
// day selected for stats view ?
if ($period == DB_ARCHIVES_PERIOD_DAY && $date->getDay() == $dateAsked->getDay() || $period == DB_ARCHIVES_PERIOD_WEEK && $date->getWeek() == $dateAsked->getWeek() || $period == DB_ARCHIVES_PERIOD_MONTH || $period == DB_ARCHIVES_PERIOD_YEAR) {
$selected = 1;
} else {
$selected = 0;
}
$weekNo = $date->getWeek() - $week;
if (defined('MONDAY_FIRST') && MONDAY_FIRST == 'no' && date("w", $ts) == 0) {
$weekNo += 1;
}
$dayOfWeek = (int) (!defined('MONDAY_FIRST') || MONDAY_FIRST == 'yes' ? date("w", $ts) == 0 ? 6 : date("w", $ts) - 1 : date("w", $ts));
$return[$weekNo][$dayOfWeek] = array('day' => substr($date->getDay(), 0, 1) === '0' ? substr($date->getDay(), 1, 2) : $date->getDay(), 'date' => $date->get(), 'exists' => $exists, 'selected' => $selected);
$date->addDays(1);
//these 2 lines useless? to check
$ts = $date->getTimeStamp();
$date->setTimestamp($ts);
}
foreach ($return as $key => $r) {
$row =& $return[$key];
for ($i = 0; $i < 7; $i++) {
if (!isset($row[$i])) {
$row[$i] = "-";
}
}
ksort($row);
}
return $return;
}
示例11: setEOV
/**
* set EOV
*
* @access public
* @param int eov of verification
*
*/
public function setEOV($a_eov)
{
include_once 'Date.php';
$date = new Date();
$date->setDate($a_eov, DATE_FORMAT_UNIXTIME);
$this->eov = $date->getDate() . '+01:00';
}
示例12: setDate
function setDate($date, $format = DATE_FORMAT_ISO)
{
if (is_array($date)) {
$this->setDateArray($date);
return;
}
if (is_int($format) && $format < 100) {
parent::setDate($date, $format);
return;
}
if ($this->getDate() == "0-01-01 00:00:00") {
// TODO: Make relative to (optional) date specified second argument
$date = strtotime($date);
parent::setDate($date);
}
}
示例13: getUTEnd
/**
* get end as unix time
*
* @access public
*
*/
public function getUTEnd()
{
include_once 'Date.php';
$date = new Date();
$date->setDate($this->end);
return $date->getDate(DATE_FORMAT_UNIXTIME);
}
示例14: Date
function testDateUnixtime4()
{
$temp = new Date();
$temp->setTZbyID("Europe/London");
$temp->setDate(strtotime("2003-10-04 14:03:24Z"));
// Summer time in London
$temp->setTZbyID("UTC");
$this->assertEquals('2003-10-04 15:03:24', sprintf('%04d-%02d-%02d %02d:%02d:%02d', $temp->year, $temp->month, $temp->day, $temp->hour, $temp->minute, $temp->second));
}
示例15: getWeeklyReport
/**
* Returns the data used by the weekly report.
*
* @access public
* @param string $usr_id The ID of the user this report is for.
* @param string The start date of this report.
* @param string The end date of this report.
* @param boolean If closed issues should be separated from other issues.
* @return array An array of data containing all the elements of the weekly report.
*/
function getWeeklyReport($usr_id, $start, $end, $separate_closed = false)
{
$usr_id = Misc::escapeInteger($usr_id);
// figure out timezone
$user_prefs = Prefs::get($usr_id);
$tz = @$user_prefs["timezone"];
$start_dt = new Date();
$end_dt = new Date();
// set timezone to that of user.
$start_dt->setTZById($tz);
$end_dt->setTZById($tz);
// set the dates in the users time zone
$start_dt->setDate($start . " 00:00:00");
$end_dt->setDate($end . " 23:59:59");
// convert time to GMT
$start_dt->toUTC();
$end_dt->toUTC();
$start_ts = $start_dt->getDate();
$end_ts = $end_dt->getDate();
$time_tracking = Time_Tracking::getSummaryByUser($usr_id, $start_ts, $end_ts);
// replace spaces in index with _ and calculate total time
$total_time = 0;
foreach ($time_tracking as $category => $data) {
unset($time_tracking[$category]);
$time_tracking[str_replace(" ", "_", $category)] = $data;
$total_time += $data["total_time"];
}
// get count of issues assigned in week of report.
$stmt = "SELECT\n COUNT(*)\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n WHERE\n iss_id = isu_iss_id AND\n iss_sta_id = sta_id AND\n isu_usr_id = {$usr_id} AND\n isu_assigned_date BETWEEN '{$start_ts}' AND '{$end_ts}'";
$newly_assigned = $GLOBALS["db_api"]->dbh->getOne($stmt);
if (PEAR::isError($newly_assigned)) {
Error_Handler::logError(array($newly_assigned->getMessage(), $newly_assigned->getDebugInfo()), __FILE__, __LINE__);
}
$email_count = array("associated" => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, true), "other" => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, false));
$data = array("start" => str_replace('-', '.', $start), "end" => str_replace('-', '.', $end), "user" => User::getDetails($usr_id), "group_name" => Group::getName(User::getGroupID($usr_id)), "issues" => History::getTouchedIssuesByUser($usr_id, $start_ts, $end_ts, $separate_closed), "status_counts" => History::getTouchedIssueCountByStatus($usr_id, $start_ts, $end_ts), "new_assigned_count" => $newly_assigned, "time_tracking" => $time_tracking, "email_count" => $email_count, "phone_count" => Phone_Support::getCountByUser($usr_id, $start_ts, $end_ts), "note_count" => Note::getCountByUser($usr_id, $start_ts, $end_ts), "total_time" => Misc::getFormattedTime($total_time, false));
return $data;
}