本文整理汇总了PHP中Date::getDay方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::getDay方法的具体用法?PHP Date::getDay怎么用?PHP Date::getDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date::getDay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDateOffset
public function testDateOffset()
{
$date = new Date('2015-04-25+01:00');
$this->assertEquals(2015, $date->getYear());
$this->assertEquals(4, $date->getMonth());
$this->assertEquals(25, $date->getDay());
$this->assertEquals(3600, $date->getOffset());
$this->assertInstanceOf('DateTimeZone', $date->getTimeZone());
$this->assertEquals('2015-04-25+01:00', $date->toString());
}
示例2: testSetByLocaleStringShort
function testSetByLocaleStringShort()
{
$date = new Date();
$locale = new Locale('en');
$date->setByLocaleString($locale, 'Thu 20 Jan 2005', '%a %d %b %Y');
$this->assertEqual($date->getMonth(), 1);
$this->assertEqual($date->getYear(), 2005);
$this->assertEqual($date->getDay(), 20);
}
示例3: getAgeByBirthDate
public static function getAgeByBirthDate(Date $birthDate, $actualDate = null)
{
if ($actualDate) {
Assert::isInstance($actualDate, 'Date');
} else {
$actualDate = Date::makeToday();
}
$result = $actualDate->getYear() - $birthDate->getYear();
if ($actualDate->getMonth() < $birthDate->getMonth() || $actualDate->getMonth() == $birthDate->getMonth() && $actualDate->getDay() < $birthDate->getDay()) {
// - Happy birthday?
// - Happy go to hell. Not yet in this year.
--$result;
}
return $result;
}
示例4: isEquals
public function isEquals(Date $date)
{
return $this->year === $date->getYear() && $this->month === $date->getMonth() && $this->day === $date->getDay();
}
示例5: getConversions
/**
* Returns an array of conversions.
*
* @param array $aParams
* @return array
*/
function getConversions($aParams)
{
$conf = $GLOBALS['_MAX']['CONF'];
$oDbh =& OA_DB::singleton();
$where = '';
if (!empty($aParams['day'])) {
$aParams['day_begin'] = $aParams['day_end'] = $aParams['day'];
}
if (!empty($aParams['day_begin'])) {
$oStart = new Date($aParams['day_begin']);
$oStart->setHour(0);
$oStart->setMinute(0);
$oStart->setSecond(0);
$oStart->toUTC();
$where .= ' AND ac.tracker_date_time >= ' . $oDbh->quote($oStart->format('%Y-%m-%d %H:%M:%S'), 'timestamp');
}
if (!empty($aParams['day_end'])) {
$oEnd = new Date($aParams['day_end']);
$oEnd->setHour(23);
$oEnd->setMinute(59);
$oEnd->setSecond(59);
$oEnd->toUTC();
$where .= ' AND ac.tracker_date_time <= ' . $oDbh->quote($oEnd->format('%Y-%m-%d %H:%M:%S'), 'timestamp');
}
if (!empty($aParams['month'])) {
$oStart = new Date("{$aParams['month']}-01");
$oStart->setHour(0);
$oStart->setMinute(0);
$oStart->setSecond(0);
$oEnd = new Date(Date_Calc::beginOfNextMonth($oStart->getDay(), $oStart->getMonth, $oStart->getYear(), '%Y-%m-%d'));
$oEnd->setHour(0);
$oEnd->setMinute(0);
$oEnd->setSecond(0);
$oEnd->subtractSeconds(1);
$oStart->toUTC();
$oEnd->toUTC();
$where .= ' AND ac.tracker_date_time >= ' . $oDbh->quote($oStart->format('%Y-%m-%d %H:%M:%S'), 'timestamp');
$where .= ' AND ac.tracker_date_time <= ' . $oDbh->quote($oEnd->format('%Y-%m-%d %H:%M:%S'), 'timestamp');
}
if (!empty($aParams['day_hour'])) {
$oStart = new Date("{$aParams['day_hour']}:00:00");
$oStart->setMinute(0);
$oStart->setSecond(0);
$oEnd = new Date($oStart);
$oStart->setMinute(59);
$oStart->setSecond(59);
$where .= ' AND ac.tracker_date_time >= ' . $oDbh->quote($oStart->format('%Y-%m-%d %H:%M:%S'), 'timestamp');
$where .= ' AND ac.tracker_date_time <= ' . $oDbh->quote($oEnd->format('%Y-%m-%d %H:%M:%S'), 'timestamp');
}
if (!empty($aParams['agency_id'])) {
$where .= ' AND c.agencyid=' . $oDbh->quote($aParams['agency_id'], 'integer');
}
if (!empty($aParams['clientid'])) {
$where .= ' AND c.clientid=' . $oDbh->quote($aParams['clientid'], 'integer');
}
if (isset($aParams['zonesIds'])) {
$where .= ' AND ac.zone_id IN (' . $oDbh->escape(implode(',', $aParams['zonesIds'])) . ")";
}
if (!empty($aParams['campaignid'])) {
$where .= ' AND m.campaignid=' . $oDbh->quote($aParams['campaignid'], 'integer');
}
if (!empty($aParams['bannerid'])) {
$where .= ' AND d.bannerid=' . $oDbh->quote($aParams['bannerid'], 'integer');
}
if (!empty($aParams['statuses'])) {
$where .= ' AND ac.connection_status IN (' . $oDbh->escape(implode(',', $aParams['statuses'])) . ')';
}
if (isset($aParams['startRecord']) && is_numeric($aParams['startRecord']) && is_numeric($aParams['perPage'])) {
$limit = ' LIMIT ' . $oDbh->quote($aParams['perPage'], 'text', false) . ' OFFSET ' . $oDbh->quote($aParams['startRecord'], 'text', false);
} elseif (!empty($aParams['perPage'])) {
$limit = ' LIMIT ' . $oDbh->quote($aParams['perPage'], 'integer', false) . ' OFFSET 0';
} else {
$limit = '';
}
$query = "SELECT\n ac.data_intermediate_ad_connection_id as connection_id,\n c.clientid,\n m.campaignid,\n m.campaignname AS campaignname,\n ac.tracker_id as tracker_id,\n ac.connection_status,\n ac.connection_date_time AS connection_date_time,\n ac.tracker_date_time as date_time,\n t.trackername,\n ac.tracker_ip_address,\n ac.tracker_country,\n ac.connection_action,\n t.type AS connection_type,\n ac.tracker_country,\n ac.ad_id,\n ac.creative_id,\n ac.zone_id,\n ac.comments\n FROM\n {$conf['table']['prefix']}{$conf['table']['clients']} AS c,\n {$conf['table']['prefix']}{$conf['table']['data_intermediate_ad_connection']} AS ac,\n {$conf['table']['prefix']}{$conf['table']['banners']} AS d,\n {$conf['table']['prefix']}{$conf['table']['campaigns']} AS m,\n {$conf['table']['prefix']}{$conf['table']['trackers']} AS t\n WHERE\n c.clientid=m.clientid\n AND m.campaignid=d.campaignid\n AND d.bannerid=ac.ad_id\n AND t.trackerid=ac.tracker_id\n AND ac.inside_window = 1\n " . $where . "\n ORDER BY\n ac.tracker_date_time\n {$limit}";
$aStats = $oDbh->queryAll($query, null, MDB2_FETCHMODE_DEFAULT, true);
$oNow = new Date();
foreach (array_keys($aStats) as $k) {
$oDate = new Date($aStats[$k]['date_time']);
$oDate->setTZbyID('UTC');
$oDate->convertTZ($oNow->tz);
$aStats[$k]['date_time'] = $oDate->format('%Y-%m-%d %H:%M:%S');
$oDate = new Date($aStats[$k]['connection_date_time']);
$oDate->setTZbyID('UTC');
$oDate->convertTZ($oNow->tz);
$aStats[$k]['connection_date_time'] = $oDate->format('%Y-%m-%d %H:%M:%S');
}
return $aStats;
}
示例6: transferFormerFinishedTransactions
function transferFormerFinishedTransactions($account)
{
global $us;
if ($us->getProperty('autoExpandPlannedTransactions') == false) {
return;
}
$now = new Date();
$now->setHour(0);
$now->setMinute(0);
$now->setSecond(0);
$account->setType('planned');
$account->setFilter(array(array('key' => 'beginDate', 'op' => 'le', 'val' => $now)));
try {
$lastInsertDate = $us->getProperty('Account_' . $account->getId() . '_LastTransferFormerFinishedTransactions');
} catch (BadgerException $ex) {
$lastInsertDate = new Date('1000-01-01');
}
$us->setProperty('Account_' . $account->getId() . '_LastTransferFormerFinishedTransactions', $now);
if (!$lastInsertDate->before($now)) {
return;
}
while ($currentTransaction = $account->getNextPlannedTransaction()) {
$date = new Date($currentTransaction->getBeginDate());
$dayOfMonth = $date->getDay();
//While we are before now and the end date of this transaction
while (!$date->after($now) && !$date->after(is_null($tmp = $currentTransaction->getEndDate()) ? new Date('9999-12-31') : $tmp)) {
if ($date->after($lastInsertDate)) {
$account->addFinishedTransaction($currentTransaction->getAmount(), $currentTransaction->getTitle(), $currentTransaction->getDescription(), new Date($date), $currentTransaction->getTransactionPartner(), $currentTransaction->getCategory(), $currentTransaction->getOutsideCapital(), false, true);
}
//do the date calculation
switch ($currentTransaction->getRepeatUnit()) {
case 'day':
$date->addSeconds($currentTransaction->getRepeatFrequency() * 24 * 60 * 60);
break;
case 'week':
$date->addSeconds($currentTransaction->getRepeatFrequency() * 7 * 24 * 60 * 60);
break;
case 'month':
//Set the month
$date = new Date(Date_Calc::endOfMonthBySpan($currentTransaction->getRepeatFrequency(), $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
//And count back as far as the last valid day of this month
while ($date->getDay() > $dayOfMonth) {
$date->subtractSeconds(24 * 60 * 60);
}
break;
case 'year':
$newYear = $date->getYear() + $currentTransaction->getRepeatFrequency();
if ($dayOfMonth == 29 && $date->getMonth() == 2 && !Date_Calc::isLeapYear($newYear)) {
$date->setDay(28);
} else {
$date->setDay($dayOfMonth);
}
$date->setYear($newYear);
break;
default:
throw new BadgerException('Account', 'IllegalRepeatUnit', $currentTransaction->getRepeatUnit());
exit;
}
}
}
}
示例7: format
/**
* Formats a
*
* @param util.Date d
* @return string
*/
public function format(Date $d)
{
$out = '';
foreach ($this->format as $token) {
switch ($token) {
case '%Y':
$out .= $d->getYear();
break;
case '%m':
$out .= str_pad($d->getMonth(), 2, '0', STR_PAD_LEFT);
break;
case '%d':
$out .= str_pad($d->getDay(), 2, '0', STR_PAD_LEFT);
break;
case '%H':
$out .= str_pad($d->getHours(), 2, '0', STR_PAD_LEFT);
break;
case '%M':
$out .= str_pad($d->getMinutes(), 2, '0', STR_PAD_LEFT);
break;
case '%S':
$out .= str_pad($d->getSeconds(), 2, '0', STR_PAD_LEFT);
break;
case '%p':
$h = $d->getHours();
$out .= $h >= 12 ? 'PM' : 'AM';
break;
case '%I':
$out .= str_pad($d->getHours() % 12, 2, '0', STR_PAD_LEFT);
break;
case '%z':
$out .= $d->getTimeZone()->getName();
break;
case '%Z':
$out .= $d->getOffset();
break;
case is_array($token):
$out .= $token[1][call_user_func(array($d, 'get' . $token[0])) - 1];
break;
default:
$out .= $token;
}
}
return $out;
}
示例8: array
/**
* DB_DataObject_FormBuilder::_date2array()
*
* Takes a string representing a date or a unix timestamp and turns it into an
* array suitable for use with the QuickForm data element.
* When using a string, make sure the format can be handled by the PEAR::Date constructor!
*
* Beware: For the date conversion to work, you must at least use the letters "d", "m" and "Y" in
* your format string (see "dateElementFormat" option). If you want to enter a time as well,
* you will have to use "H", "i" and "s" as well. Other letters will not work! Exception: You can
* also use "M" instead of "m" if you want plain text month names.
*
* @param mixed $date A unix timestamp or the string representation of a date, compatible to strtotime()
* @return array
* @access protected
*/
function _date2array($date)
{
$da = array();
if (is_string($date)) {
// Get PEAR::Date class definition, if needed
include_once 'Date.php';
$dObj = new Date($date);
$da['d'] = $dObj->getDay();
$da['l'] = $da['D'] = $dObj->getDayOfWeek();
$da['m'] = $da['M'] = $da['F'] = $dObj->getMonth();
$da['Y'] = $da['y'] = $dObj->getYear();
$da['H'] = $dObj->getHour();
$da['h'] = $da['H'] % 12;
if ($da['h'] == 0) {
$da['h'] = 12;
}
$da['i'] = $dObj->getMinute();
$da['s'] = $dObj->getSecond();
if ($da['H'] >= 12) {
$da['a'] = 'pm';
$da['A'] = 'PM';
} else {
$da['a'] = 'am';
$da['A'] = 'AM';
}
unset($dObj);
} else {
if (is_int($date)) {
$time = $date;
} else {
$time = time();
}
$da['d'] = date('d', $time);
$da['l'] = $da['D'] = date('w', $time);
$da['m'] = $da['M'] = $da['F'] = date('m', $time);
$da['Y'] = $da['y'] = date('Y', $time);
$da['H'] = date('H', $time);
$da['h'] = date('h', $time);
$da['i'] = date('i', $time);
$da['s'] = date('s', $time);
$da['a'] = date('a', $time);
$da['A'] = date('A', $time);
}
$this->debug('<i>_date2array():</i> from ' . $date . ' ...');
return $da;
}
示例9: isToday
/**
* Checks if the given day is the current day
*
* @param mixed $stamp Any timestamp format recognized by Pear::Date
*
* @return boolean
* @access protected
*/
function isToday($stamp)
{
static $today = null;
if (is_null($today)) {
$today = new Date();
}
$date = Calendar_Engine_PearDate::stampCollection($stamp);
return $date->day == $today->getDay() && $date->month == $today->getMonth() && $date->year == $today->getYear();
}
示例10: computeSubscriptionDays
private function computeSubscriptionDays($p_publication, $p_subscriptionTime) {
$startDate = new Date();
if ($p_publication->getTimeUnit() == 'D') {
return $p_subscriptionTime;
} elseif ($p_publication->getTimeUnit() == 'W') {
return 7 * $p_subscriptionTime;
} elseif ($p_publication->getTimeUnit() == 'M') {
$endDate = new Date();
$months = $p_subscriptionTime + $endDate->getMonth();
$years = (int)($months / 12);
$months = $months % 12;
$endDate->setYear($endDate->getYear() + $years);
$endDate->setMonth($months);
} elseif ($p_publication->getTimeUnit() == 'Y') {
$endDate = new Date();
$endDate->setYear($endDate->getYear() + $p_subscriptionTime);
}
$dateCalc = new Date_Calc();
return $dateCalc->dateDiff($endDate->getDay(), $endDate->getMonth(),
$endDate->getYear(), $startDate->getDay(), $startDate->getMonth(), $startDate->getYear());
}
示例11: testGetDay
/**
* @covers Geissler\Converter\Model\Date::getDay
*/
public function testGetDay()
{
$this->assertInstanceOf($this->class, $this->object->setDay(19));
$this->assertEquals(19, $this->object->getDay());
}
示例12: dosDate
/**
* Returns a date in the format used by MS-DOS.
*
* @see http://www.vsft.com/hal/dostime.htm
* @param util.Date date
* @return int
*/
protected function dosDate(Date $date)
{
return (($date->getYear() - 1980 & 0x7f) << 4 | $date->getMonth() & 0xf) << 5 | $date->getDay() & 0x1f;
}
示例13: updateDuplicarTareaFromRequest
/**
* Actualiza los datos de la tarea duplicada.
* @version 26-02-09
* @author Ana Martín
*/
protected function updateDuplicarTareaFromRequest()
{
$tarea = $this->getRequestParameter('tarea');
$value = sfContext::getInstance()->getI18N()->getTimestampForCulture($tarea['fecha_inicio']['date'], $this->getUser()->getCulture());
$mi_date = new Date($value);
$mi_date->setHours(isset($tarea['fecha_inicio']['hour']) ? $tarea['fecha_inicio']['hour'] : 0);
$mi_date->setMinutes(isset($tarea['fecha_inicio']['minute']) ? $tarea['fecha_inicio']['minute'] : 0);
$this->nueva_tarea->setFechaInicio($mi_date->getTimestamp());
if (isset($tarea['fecha_vencimiento'])) {
$value = sfContext::getInstance()->getI18N()->getTimestampForCulture($tarea['fecha_vencimiento']['date'], $this->getUser()->getCulture());
$mi_date = new Date($value);
$mi_date->setHours(isset($tarea['fecha_vencimiento']['hour']) ? $tarea['fecha_vencimiento']['hour'] : 0);
$mi_date->setMinutes(isset($tarea['fecha_vencimiento']['minute']) ? $tarea['fecha_vencimiento']['minute'] : 0);
$this->nueva_tarea->setFechaVencimiento($mi_date->getTimestamp());
} else {
if (isset($tarea['duracion'])) {
$duracion_minutos = $tarea['duracion'];
$fecha_vencimiento = mktime($mi_date->getHours(), $mi_date->getMinutes() + $duracion_minutos, 0, $mi_date->getMonth(), $mi_date->getDay(), $mi_date->getYear());
$this->nueva_tarea->setFechaVencimiento(date('Y-m-d H:i', $fecha_vencimiento));
} else {
$this->nueva_tarea->setFechaVencimiento($mi_date->getTimestamp());
}
}
if (isset($tarea['id_usuario'])) {
$this->nueva_tarea->setIdUsuario($tarea['id_usuario']);
}
}
示例14: 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;
}
示例15: dayDifference
public static function dayDifference(Date $left, Date $right)
{
return gregoriantojd($right->getMonth(), $right->getDay(), $right->getYear()) - gregoriantojd($left->getMonth(), $left->getDay(), $left->getYear());
}