本文整理汇总了PHP中Date::get_day方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::get_day方法的具体用法?PHP Date::get_day怎么用?PHP Date::get_day使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date::get_day方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_reference_date
private static function get_reference_date()
{
$reference_date = new Date();
$life_time = self::get_life_time();
$reference_date->set_day($reference_date->get_day() - $life_time);
return $reference_date;
}
示例2: on_changeday
public function on_changeday(Date $yesterday, Date $today)
{
try {
$result = PersistenceContext::get_querier()->insert(StatsSetup::$stats_table, array('stats_year' => $yesterday->get_year(Timezone::SERVER_TIMEZONE), 'stats_month' => $yesterday->get_month(Timezone::SERVER_TIMEZONE), 'stats_day' => $yesterday->get_day(Timezone::SERVER_TIMEZONE), 'nbr' => 0, 'pages' => 0, 'pages_detail' => ''));
//We retrieve the id we just come to create
$last_stats = $result->get_last_inserted_id();
} catch (MySQLQuerierException $e) {
$last_stats = PersistenceContext::get_querier()->get_column_value(StatsSetup::$stats_table, 'id', 'WHERE stats_year = :stats_year AND stats_month = :stats_month AND stats_day = :stats_day', array('stats_year' => $yesterday->get_year(Timezone::SERVER_TIMEZONE), 'stats_month' => $yesterday->get_month(Timezone::SERVER_TIMEZONE), 'stats_day' => $yesterday->get_day(Timezone::SERVER_TIMEZONE)));
}
PersistenceContext::get_querier()->inject("UPDATE " . StatsSetup::$stats_referer_table . " SET yesterday_visit = today_visit, today_visit = 0, nbr_day = nbr_day + 1");
//We delete the referer entries older than one week
PersistenceContext::get_querier()->delete(StatsSetup::$stats_referer_table, 'WHERE last_update < :last_update', array('last_update' => time() - 604800));
//We retrieve the number of pages seen until now
$pages_displayed = StatsSaver::retrieve_stats('pages');
//We delete the file containing the displayed pages
$pages_file = new File(PATH_TO_ROOT . '/stats/cache/pages.txt');
$pages_file->delete();
//How much visitors were there today?
$total_visit = PersistenceContext::get_querier()->get_column_value(DB_TABLE_VISIT_COUNTER, 'total', 'WHERE id = 1');
//We update the stats table: the number of visits today
PersistenceContext::get_querier()->update(StatsSetup::$stats_table, array('nbr' => $total_visit, 'pages' => array_sum($pages_displayed), 'pages_detail' => serialize($pages_displayed)), 'WHERE id=:id', array('id' => $last_stats));
}
示例3: execute
public function execute(array $args)
{
if (count($args) == 0) {
$date = new Date();
$file_name = PATH_TO_ROOT . '/cache/backup/dump_' . $date->get_year() . '-' . $date->get_month() . '-' . $date->get_day() . '_' . $date->get_hours() . 'h' . $date->get_minutes() . '.sql';
} else {
$file_name = $args[0];
array_shift($args);
}
$tables = null;
foreach ($args as $arg) {
$tables[] = $arg;
}
$this->dump($file_name, $tables);
}
示例4: trim
$field = $request->get_getvalue('field', '');
$input_field = $request->get_getvalue('input_field', '');
$input_date = $request->get_getvalue('input_date', '');
$calendar_number = $request->get_getvalue('calendar_number', '');
//Vide par défaut => Type date.
$calendar_type = !empty($date) ? 'timestamp' : 'date';
$field = !empty($field) ? trim($field) : 'calendar';
$date_lang = LangLoader::get('date-common');
$tpl = new FileTemplate('framework/util/mini_calendar_response.tpl');
$tpl->add_lang($date_lang);
//Type date.
if ($calendar_type == 'date') {
$now = new Date();
$year = $request->get_getint('y', $now->get_year());
$month = $request->get_getint('m', $now->get_month());
$day = $request->get_getint('d', $now->get_day());
$input_date = !empty($input_date) ? trim($input_date) : $day . '/' . $month . '/' . $year;
$selected = explode('/', $input_date);
$selected_day = NumberHelper::numeric($selected[0]);
$selected_month = NumberHelper::numeric($selected[1]);
$selected_year = NumberHelper::numeric($selected[2]);
if (!checkdate($month, $day, $year)) {
list($year, $month, $day) = array(date('Y'), date('n'), date('j'));
}
$bissextile = date("L", mktime(0, 0, 0, 1, 1, $year)) == 1 ? 29 : 28;
$array_month = array(31, $bissextile, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$array_l_month = array($date_lang['january'], $date_lang['february'], $date_lang['march'], $date_lang['april'], $date_lang['may'], $date_lang['june'], $date_lang['july'], $date_lang['august'], $date_lang['september'], $date_lang['october'], $date_lang['november'], $date_lang['december']);
$month_day = $array_month[$month - 1];
$tpl->put_all(array('FIELD' => $field, 'INPUT_FIELD' => $input_field, 'CALENDAR_NUMBER' => $calendar_number, 'MONTH' => $month, 'YEAR' => $year, 'PREVIOUS_YEAR' => $month == 1 ? $year - 1 : $year, 'PREVIOUS_MONTH' => $month == 1 ? 12 : $month - 1, 'NEXT_YEAR' => $month == 12 ? $year + 1 : $year, 'NEXT_MONTH' => $month == 12 ? 1 : $month + 1));
//Génération des select.
for ($i = 1; $i <= 12; $i++) {
示例5: optimize_database_tables
private static function optimize_database_tables(Date $current_date)
{
if (ModulesManager::is_module_installed('database')) {
$database_config = DatabaseConfig::load();
if ($database_config->is_database_tables_optimization_enabled()) {
if ($database_config->get_database_tables_optimization_day() == 7 && $current_date->get_day() == 1 || $database_config->get_database_tables_optimization_day() == $current_date->get_day_of_week()) {
$tables_to_optimize = array();
foreach (PersistenceContext::get_dbms_utils()->list_and_desc_tables(true) as $key => $table_info) {
if (NumberHelper::round($table_info['data_free'] / 1024, 1) != 0) {
$tables_to_optimize[] = $key;
}
}
PersistenceContext::get_dbms_utils()->optimize($tables_to_optimize);
}
}
}
}
示例6: send_mail
private function send_mail()
{
$message = '';
$current_user = AppContext::get_current_user();
$fields = $this->config->get_fields();
$recipients_field_id = $this->config->get_field_id_by_name('f_recipients');
$recipients_field = new ContactField();
$recipients_field->set_properties($fields[$recipients_field_id]);
$recipients = $recipients_field->get_possible_values();
$recipients['admins']['email'] = implode(';', MailServiceConfig::load()->get_administrators_mails());
$subject_field_id = $this->config->get_field_id_by_name('f_subject');
$subject_field = new ContactField();
$subject_field->set_properties($fields[$subject_field_id]);
$subjects = $subject_field->get_possible_values();
if ($subject_field->get_field_type() == 'ContactShortTextField') {
$subject = $this->form->get_value('f_subject');
} else {
$subject = $this->form->get_value('f_subject')->get_raw_value();
}
$display_message_title = false;
if ($this->config->is_tracking_number_enabled()) {
$now = new Date();
$tracking_number = $this->config->get_last_tracking_number();
$tracking_number++;
$message .= $this->lang['contact.tracking_number'] . ' : ' . ($this->config->is_date_in_tracking_number_enabled() ? $now->get_year() . $now->get_month() . $now->get_day() . '-' : '') . $tracking_number . '
';
$this->config->set_last_tracking_number($tracking_number);
ContactConfig::save();
$subject = '[' . $tracking_number . '] ' . $subject;
$display_message_title = true;
}
foreach ($this->config->get_fields() as $id => $properties) {
$field = new ContactField();
$field->set_properties($properties);
if ($field->is_displayed() && $field->is_authorized() && $field->is_deletable()) {
try {
$value = ContactFieldsService::get_value($this->form, $field);
$message .= $field->get_name() . ': ' . $value . '
';
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
$display_message_title = true;
}
}
if ($display_message_title) {
$message .= $this->lang['contact.form.message'] . ':
';
}
$message .= $this->form->get_value('f_message');
$mail = new Mail();
$mail->set_sender(MailServiceConfig::load()->get_default_mail_sender(), $this->lang['module_title']);
$mail->set_reply_to($this->form->get_value('f_sender_mail'), $current_user->get_level() == User::VISITOR_LEVEL ? $this->lang['module_title'] : $current_user->get_display_name());
$mail->set_subject($subject);
$mail->set_content($message);
if ($recipients_field->is_displayed()) {
if (in_array($recipients_field->get_field_type(), array('ContactSimpleSelectField', 'ContactSimpleChoiceField'))) {
$recipients_mails = explode(';', $recipients[$this->form->get_value('f_recipients')->get_raw_value()]['email']);
} else {
$selected_recipients = $this->form->get_value('f_recipients');
$recipients_mails = array();
foreach ($selected_recipients as $recipient) {
$mails = explode(';', $recipients[$recipient->get_id()]['email']);
foreach ($mails as $m) {
$recipients_mails[] = $m;
}
}
}
foreach ($recipients_mails as $mail_address) {
$mail->add_recipient($mail_address);
}
} else {
if ($subject_field->get_field_type() != 'ContactShortTextField') {
$recipient = $subjects[$this->form->get_value('f_subject')->get_raw_value()]['recipient'];
$recipients_mails = explode(';', $recipients[$recipient]['email']);
foreach ($recipients_mails as $mail_address) {
$mail->add_recipient($mail_address);
}
} else {
$recipients_mails = explode(';', $recipients['admins']['email']);
foreach ($recipients_mails as $mail_address) {
$mail->add_recipient($mail_address);
}
}
}
$mail_service = AppContext::get_mail_service();
if ($this->config->is_sender_acknowledgment_enabled()) {
$acknowledgment = new Mail();
$acknowledgment->set_sender(MailServiceConfig::load()->get_default_mail_sender(), Mail::SENDER_ADMIN);
$acknowledgment->set_subject('[' . $this->lang['contact.acknowledgment_title'] . '] ' . $subject);
$acknowledgment->set_content($this->lang['contact.acknowledgment'] . $message);
$acknowledgment->add_recipient($this->form->get_value('f_sender_mail'));
return $mail_service->try_to_send($mail) && $mail_service->try_to_send($acknowledgment);
}
return $mail_service->try_to_send($mail);
}
示例7: set_last_use_date
/**
* Sets the date of the last time PHPBoost executed the daily tasks.
* @param Date $date The date
*/
public function set_last_use_date(Date $date)
{
$this->set_property('year', $date->get_year());
$this->set_property('month', $date->get_month());
$this->set_property('day', $date->get_day());
}
示例8: on_changeday
/**
* {@inheritDoc}
*/
public function on_changeday(Date $yesterday, Date $today)
{
if ($today->get_day() == 1) {
CalendarCurrentMonthEventsCache::invalidate();
}
}
示例9: build_view
private function build_view(HTTPRequestCustom $request)
{
$config = CalendarConfig::load();
$categories = CalendarService::get_categories_manager()->get_categories_cache()->get_categories();
$year = $this->year ? $this->year : min($request->get_int('calendar_ajax_year', date('Y')), 2037);
$month = $this->month ? $this->month : min($request->get_int('calendar_ajax_month', date('n')), 12);
$bissextile = date("L", mktime(0, 0, 0, 1, 1, $year)) == 1 ? 29 : 28;
$array_month = array(31, $bissextile, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$array_l_month = array($this->lang['january'], $this->lang['february'], $this->lang['march'], $this->lang['april'], $this->lang['may'], $this->lang['june'], $this->lang['july'], $this->lang['august'], $this->lang['september'], $this->lang['october'], $this->lang['november'], $this->lang['december']);
$month_days = $array_month[$month - 1];
$previous_month = $month == 1 ? 12 : $month - 1;
$previous_year = $month == 1 ? $year - 1 : $year;
$next_month = $month == 12 ? 1 : $month + 1;
$next_year = $month == 12 ? $year + 1 : $year;
//Months
for ($i = 1; $i <= 12; $i++) {
$this->view->assign_block_vars('months', array('VALUE' => $i, 'NAME' => $array_l_month[$i - 1], 'SELECTED' => $month == $i));
}
//Years
for ($i = 1970; $i <= 2037; $i++) {
$this->view->assign_block_vars('years', array('VALUE' => $i, 'NAME' => $i, 'SELECTED' => $year == $i));
}
//Retrieve all the events of the selected month
$events = $month == date('n') && $year == date('Y') ? CalendarCurrentMonthEventsCache::load()->get_events() : CalendarService::get_all_current_month_events($month, $year, $month_days);
$events_legends_list = array();
foreach ($events as $event) {
$start_date = new Date($event['start_date'], Timezone::SERVER_TIMEZONE);
$end_date = new Date($event['end_date'], Timezone::SERVER_TIMEZONE);
if (($end_date->get_month() > $start_date->get_month() || $end_date->get_year() > $start_date->get_year()) && $month == $start_date->get_month()) {
$first_event_day = $start_date->get_day();
$last_event_day = $array_month[$month - 1];
} else {
if (($end_date->get_month() > $start_date->get_month() || $end_date->get_year() > $start_date->get_year()) && $month == $end_date->get_month()) {
$first_event_day = 1;
$last_event_day = $end_date->get_day();
} else {
if (($end_date->get_month() > $start_date->get_month() || $end_date->get_year() > $start_date->get_year()) && $month > $start_date->get_month() && $month < $end_date->get_month()) {
$first_event_day = 1;
$last_event_day = $array_month[$month - 1];
} else {
$first_event_day = $start_date->get_day();
$last_event_day = $end_date->get_day();
}
}
}
for ($j = $first_event_day; $j <= $last_event_day; $j++) {
if ($event['type'] == 'EVENT' || $event['type'] == 'BIRTHDAY') {
$title = isset($array_events[$j]['title']) ? $array_events[$j]['title'] : '';
$array_events[$j] = array('title' => $title . (!empty($title) ? '
' : '') . ($event['type'] != 'BIRTHDAY' ? $j == $start_date->get_day() && $month == $start_date->get_month() && $year == $start_date->get_year() ? $start_date->get_hours() . 'h' . $start_date->get_minutes() . ' : ' : '' : LangLoader::get_message('calendar.labels.birthday_title', 'common', 'calendar') . ' ') . $event['title'], 'type' => $event['type'], 'color' => $event['type'] == 'BIRTHDAY' ? $config->get_birthday_color() : ($event['id_category'] != Category::ROOT_CATEGORY && $categories[$event['id_category']]->get_color() ? $categories[$event['id_category']]->get_color() : $config->get_event_color()), 'id_category' => $event['id_category']);
if ($event['type'] == 'BIRTHDAY') {
$events_legends_list[$j] = array('name' => LangLoader::get_message('calendar.labels.birthday', 'common', 'calendar'), 'color' => $config->get_birthday_color());
} else {
if ($event['type'] == 'EVENT' && $event['id_category'] == Category::ROOT_CATEGORY) {
$events_legends_list[$j] = array('name' => LangLoader::get_message('calendar.titles.event', 'common', 'calendar'), 'color' => $config->get_event_color());
} else {
if (!isset($events_legends_list[$event['id_category']])) {
$events_legends_list[$j] = array('name' => $categories[$event['id_category']]->get_name(), 'color' => $categories[$event['id_category']]->get_color());
}
}
}
}
}
}
$this->view->put_all(array('C_MINI_MODULE' => $this->is_mini_calendar(), 'C_DISPLAY_LEGEND' => !empty($events_legends_list) && !$this->is_mini_calendar(), 'DATE' => $array_l_month[$month - 1] . ' ' . $year, 'MINI_MODULE' => (int) $this->is_mini_calendar(), 'PREVIOUS_MONTH_TITLE' => $month == 1 ? $array_l_month[11] . ' ' . ($year - 1) : $array_l_month[$month - 2] . ' ' . $year, 'PREVIOUS_YEAR' => $previous_year, 'PREVIOUS_MONTH' => $previous_month, 'NEXT_MONTH_TITLE' => $month == 12 ? $array_l_month[0] . ' ' . ($year + 1) : $array_l_month[$month] . ' ' . $year, 'NEXT_YEAR' => $next_year, 'NEXT_MONTH' => $next_month, 'LEGEND' => self::build_legend($events_legends_list), 'U_AJAX_CALENDAR' => CalendarUrlBuilder::ajax_month_calendar()->rel(), 'U_AJAX_EVENTS' => CalendarUrlBuilder::ajax_month_events()->rel()));
//First day of the month
$first_day = date('w', @mktime(1, 0, 0, $month, 1, $year));
if ($first_day == 0) {
$first_day = 7;
}
//Calendar generation
$day = 1;
$last_day = $month_days + $first_day;
for ($i = 1; $i <= 56; $i++) {
$birthday_day = $color = false;
if ($i % 8 == 1 && $i < $last_day) {
$content = date('W', mktime(0, 0, 0, $month, $day, $year));
$class = 'calendar-week';
$last_day++;
} else {
if ($i >= $first_day + 1 && $i < $last_day) {
if ($day == date("j") && $month == date("m") && $year == date("Y")) {
$class = 'calendar-today';
} else {
if (!empty($array_events[$day])) {
$birthday_day = $array_events[$day]['type'] == 'BIRTHDAY';
$color = $array_events[$day]['color'];
$class = '';
} else {
if ($i % 8 == 7 || $i % 8 == 0) {
$class = 'calendar-weekend';
} else {
$class = 'calendar-other';
}
}
}
$content = $day;
$day++;
} else {
if (($i % 8 == 7 || $i % 8 == 0) && $i > $first_day && $day <= $month_days) {
//.........这里部分代码省略.........
示例10: test_set_day
public function test_set_day()
{
$date = new Date();
$date->set_day(3);
self::assertEquals(3, $date->get_day());
}