本文整理汇总了PHP中getdate函数的典型用法代码示例。如果您正苦于以下问题:PHP getdate函数的具体用法?PHP getdate怎么用?PHP getdate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getdate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
$valid = $this->form_validation;
$valid->set_rules('txtemail', 'Email', 'trim|required|valid_email');
$valid->set_rules('txttitle', 'Tiêu đề', 'trim|required');
$valid->set_rules('txtnoidung', 'Nội dung', 'trim|required');
if ($valid->run() == FALSE) {
$data['error'] = "Bạn điền thông tin đầy đủ";
$this->render($this->load->view('contact/show', $data, TRUE));
} else {
$now = getdate();
$currentDate = $now["mday"] . "-" . $now["mon"] . "-" . $now["year"];
$data['email'] = $this->input->post('txtemail');
$data['title'] = $this->input->post('txttitle');
$data['info'] = $this->input->post('txtnoidung');
$data['add_date'] = $currentDate;
$act = $this->input->post('ok');
if ($act == "Liên hệ") {
if (!$this->Mcontact->add($data)) {
$data['error'] = "Cảm ơn bạn chúng tôi sẽ hồi âm lại!";
}
}
$this->render($this->load->view('contact/show', $data, TRUE));
}
}
示例2: apiRequest
/** Make a foursquare API request.
* @param str $endpoint API endpoint to access
* @param str $access_token OAuth token for the user
* @param arr $fields Array of URL parameters
* @return array Decoded JSON response
*/
public function apiRequest($endpoint, $access_token, $fields = null)
{
// Add endpoint and OAuth token to the URL
$url = $this->api_domain . $endpoint . '?oauth_token=' . $access_token;
// If there are additional parameters passed in add them to the URL also
if ($fields != null) {
foreach ($fields as $key => $value) {
$url = $url . '&' . $key . '=' . $value;
}
}
// Foursquare requires us to add the date at the end of the request so get a date array
$date = getdate();
// Add the year month and day at the end of the URL
$url = $url . "&v=" . $date['year'] . $date['mon'] . $date['mday'];
// Get any results returned from this request
$result = Utils::getURLContents($url);
// Return the results
$parsed_result = json_decode($result);
if (isset($parsed_result->meta->errorType)) {
$exception_description = $parsed_result->meta->errorType;
if (isset($parsed_result->meta->errorDetail)) {
$exception_description .= ": " . $parsed_result->meta->errorDetail;
}
throw new Exception($exception_description);
} else {
return $parsed_result;
}
}
示例3: macro_Age
function macro_Age($formatter, $value = '')
{
if (empty($value)) {
$text = '';
} else {
if (is_numeric($value)) {
$n_year = (int) date('Y');
$text = $n_year - $value;
} else {
$now_date = getdate(time());
$n_year = (int) date('Y');
$n_month = (int) date('m');
$n_day = (int) date('d');
$values = explode('/', $value);
$v_year = $values[0];
$v_month = $values[1];
$v_day = $values[2];
$age = 0;
$age = $n_year - $v_year;
if ($n_month >= $v_month && $n_day >= $v_day) {
$age = $age + 1;
}
$text = $age;
}
}
return "{$text}";
}
示例4: tTimeFormat
/**
* timestamp转换成显示时间格式
* @param $timestamp
* @return unknown_type
*/
public static function tTimeFormat($timestamp)
{
$curTime = time();
$space = $curTime - $timestamp;
//1分钟
if ($space < 60) {
$string = "刚刚";
return $string;
} elseif ($space < 3600) {
//一小时前
$string = floor($space / 60) . "分钟前";
return $string;
}
$curtimeArray = getdate($curTime);
$timeArray = getDate($timestamp);
if ($curtimeArray['year'] == $timeArray['year']) {
if ($curtimeArray['yday'] == $timeArray['yday']) {
$format = "%H:%M";
$string = strftime($format, $timestamp);
return "今天 {$string}";
} elseif ($curtimeArray['yday'] - 1 == $timeArray['yday']) {
$format = "%H:%M";
$string = strftime($format, $timestamp);
return "昨天 {$string}";
} else {
$string = sprintf("%d月%d日 %02d:%02d", $timeArray['mon'], $timeArray['mday'], $timeArray['hours'], $timeArray['minutes']);
return $string;
}
}
$string = sprintf("%d年%d月%d日 %02d:%02d", $timeArray['year'], $timeArray['mon'], $timeArray['mday'], $timeArray['hours'], $timeArray['minutes']);
return $string;
}
示例5: get_day_of_month_future_timestamp
/**
* Получить timestamp следующей даты с указанным днём недели
*/
protected function get_day_of_month_future_timestamp($day_of_month, $hours, $minutes)
{
if ($day_of_month > 31) {
$day_of_month = 1;
}
// WTF do you want?
// (а) день будет в этом месяце
// (б) в этом месяце уже прошёл этот день
// (в) в месяце нет этого дня (29, 30, 31 число)
$now = getdate();
$month = $now["mon"];
$year = $now["year"];
if ($now["mday"] > $day_of_month || $now["mday"] == $day_of_month && $now["hours"] * 60 + $now["minutes"] > $hours * 60 + $minutes) {
// поезд ушёл
if ($month == 12) {
$year++;
$month = 1;
} else {
$month++;
}
}
$days_in_month = array(0, 31, $year % 4 ? 28 : 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if ($days_in_month[$month] < $day_of_month) {
// к счастью в декабре 31 день, а за коротким месяцем всегда идёт длинный
$month++;
}
return mktime($hours, $minutes, 0, $month, $day_of_month, $year);
}
示例6: specific_definition
protected function specific_definition($mform)
{
global $CFG, $DB;
$alerttypes = array(0 => 'NONE', 1 => 'In Zero Cluster', 2 => 'Lowest 10% scores in Cluster');
$tabletypes = array('overall' => 'All activities and marks(Overall)', 'overall_activities' => 'All activities(Overall Activities)', 'overall_marks' => 'Overall marks received (Overall Marks)', 'log' => 'Any activity (Log)', 'post' => 'Post activity (Post)', 'comments' => 'Comments activity (Comments)', 'forum_discussions' => 'Forum discussions (Forum Discussions)', 'forum_posts' => 'Forum posts (Forum Posts)', 'forum_postsResponder' => 'Responding to forum posts(Forum Posts Responder)', 'user_lastaccess' => 'User last access (User Lastaccess)', 'quiz_attempts' => 'Attempting quizzes (Quiz Attempt)', 'quiz_grades' => 'Grade in quizzes (Quiz Grades)', 'grade_grades' => 'Grades received (Grade Grades)', 'grade_gradesParticipation' => 'Participation in grade activity (Grade Grades Participation)', 'assignment_submissions' => 'Submission of assignment (Assignment Submisstions)', 'lesson_grades' => 'Grades received from lesson (Lesson Grades)', 'question_attempt_steps' => 'Attempts at question (Question Attempt Steps)', 'message' => 'Unread message created by user (Message)', 'messageTo' => 'Unread message created to user (Message To)', 'message_read' => 'Read message created by user (Message Read)', 'message_readTo' => 'Read message created to user (Lesson Grades)', 'chat_messages' => 'Chat messages (Chat message)', 'tag' => 'Tags (Tags)', 'files' => 'Files created (Files)', 'my_pages' => 'My page created by user(My Pages)', 'wiki_pages' => 'Created wiki pages (Wiki |Pages)', 'event' => 'Events created (Events)');
$today = getdate();
$courseid = $this->page->course->id;
$mform->addElement('header', 'configheader', get_string('alerts', 'block_itutor_profiler'));
$alerts = $DB->get_records('block_itutor_profiler_alerts', array('course_id' => $courseid));
foreach ($alerts as $alert) {
$dateOfAlert = getdate($alert->alert_date);
if ($today['yday'] > $dateOfAlert['yday'] && $today['year'] == $dateOfAlert['year'] || $today['year'] < $dateOfAlert['year']) {
$DB->delete_records('block_itutor_profiler_alerts', array('id' => $alert->id));
} else {
$s = 'config_isalerting' . $alert->id;
$mform->addElement('checkbox', $s, "DATE: {$dateOfAlert['mday']}/{$dateOfAlert['mon']}/{$dateOfAlert['year']} TYPE: {$alerttypes[$alert->alert_type]} DATA: {$alert->alert_data}");
$mform->setDefault($s, true);
$mform->setType($s, PARAM_BOOL);
}
}
$mform->addElement('header', 'addalertheader', get_string('addalert', 'block_itutor_profiler'));
$mform->addElement('hidden', 'config_courseid', $courseid);
$mform->addElement('date_selector', 'config_alertdate', get_string('alertday', 'block_itutor_profiler'), array('optional' => false));
$mform->addElement('select', 'config_alerttype', get_string('alerttype', 'block_itutor_profiler'), $alerttypes);
$mform->addElement('select', 'config_alertdata', get_string('alertdata', 'block_itutor_profiler'), $tabletypes);
$mform->addElement('textarea', 'config_alertmessage', get_string('alertmessage', 'block_itutor_profiler'), 'wrap="virtual" rows="20" cols="50"');
$mform->addElement('checkbox', 'config_sendtostaff', get_string('alerttostaff', 'block_itutor_profiler'));
$mform->setDefault('config_sendtostaff', true);
$mform->setType('config_sendtostaff', PARAM_BOOL);
}
示例7: api
public function api()
{
$this->loadLanguage('default_authorizenet_aim/default_authorizenet_aim');
$data['text_credit_card'] = $this->language->get('text_credit_card');
$data['entry_cc_owner'] = $this->language->get('entry_cc_owner');
$data['cc_owner'] = array('type' => 'input', 'name' => 'cc_owner', 'required' => true, 'value' => '');
$data['entry_cc_number'] = $this->language->get('entry_cc_number');
$data['cc_number'] = array('type' => 'input', 'name' => 'cc_number', 'required' => true, 'value' => '');
$data['entry_cc_expire_date'] = $this->language->get('entry_cc_expire_date');
$data['entry_cc_cvv2'] = $this->language->get('entry_cc_cvv2');
$data['entry_cc_cvv2_short'] = $this->language->get('entry_cc_cvv2_short');
$data['cc_cvv2_help_url'] = $this->html->getURL('r/extension/default_authorizenet_aim/cvv2_help');
$data['cc_cvv2'] = array('type' => 'input', 'name' => 'cc_cvv2', 'value' => '', 'style' => 'short input-small', 'required' => true, 'attr' => ' size="3"');
$data['button_confirm'] = $this->language->get('button_confirm');
$data['button_back'] = $this->language->get('button_back');
$months = array();
for ($i = 1; $i <= 12; $i++) {
$months[sprintf('%02d', $i)] = strftime('%B', mktime(0, 0, 0, $i, 1, 2000));
}
$data['cc_expire_date_month'] = array('type' => 'selectbox', 'name' => 'cc_expire_date_month', 'value' => sprintf('%02d', date('m')), 'options' => $months, 'required' => true, 'style' => 'short input-small');
$today = getdate();
$years = array();
for ($i = $today['year']; $i < $today['year'] + 11; $i++) {
$years[strftime('%Y', mktime(0, 0, 0, 1, 1, $i))] = strftime('%Y', mktime(0, 0, 0, 1, 1, $i));
}
$data['cc_expire_date_year'] = array('type' => 'selectbox', 'name' => 'cc_expire_date_year', 'value' => sprintf('%02d', date('Y') + 1), 'options' => $years, 'required' => true, 'style' => 'short input-small');
$data['process_rt'] = 'default_authorizenet_aim/send';
$this->load->library('json');
$this->response->setOutput(AJson::encode($data));
}
示例8: contact
function contact()
{
$this->load->model('log_model');
$user_id = '';
//header
$header = new header();
$header->index("Liên hệ", '', '');
//proccessing
$is_logged_in = $this->session->userdata('is_logged_in');
if (!isset($is_logged_in) || $is_logged_in != true) {
$user_id = '0';
$data['name'] = '';
$data['email'] = '';
} else {
$user_id = $this->log_model->getId();
$user_data = $this->db->select('NAME,EMAIL')->from('qtht_users')->where('ID_U', $user_id)->get()->result_array();
foreach ($user_data as $key) {
}
$data['name'] = $key['NAME'];
$data['email'] = $key['EMAIL'];
}
//end proccessing
if (isset($_REQUEST['csrf_test_name'])) {
$date = getdate();
$date_send = $date['year'] . '-' . $date['mon'] . '-' . $date['mday'] . ' ' . $date['hours'] . ':' . $date['minutes'] . ':' . $date['seconds'];
$data = array('DATE_SEND' => $date_send, 'ID_U' => $user_id, 'EMAIL' => $_REQUEST['email'], 'NAME' => $_REQUEST['name'], 'CONTENT' => $_REQUEST['content']);
$this->db->insert('qtht_contact', $data);
}
//view
$data['csrf_test_name'] = $this->security->get_csrf_hash();
$this->load->view('home/contact', $data);
}
示例9: log_msg
function log_msg($message)
{
global $logfp;
$now_array = getdate();
$now_string = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $now_array['year'], $now_array['mon'], $now_array['mday'], $now_array['hours'], $now_array['minutes'], $now_array['seconds']);
fwrite($logfp, "[{$now_string}] {$message}\n");
}
示例10: _init_search_engine
private function _init_search_engine($data)
{
$CI =& get_instance();
$min_duration = $CI->config->item('parking_min_duration');
$max_duration = $CI->config->item('parking_max_duration');
$assets_version = $CI->config->item('parking_assets_version');
$data_search = array();
$day = empty($data['day']) ? -1 : $data['day'];
$hour = empty($data['hour']) ? -1 : $data['hour'];
$duration = empty($data['duration']) ? -1 : $data['duration'];
$now = getdate();
$year_day = $now['yday'];
if (!is_numeric($day) || $day < 1 || $day > 7) {
$day = $now['wday'] == 0 ? 7 : $now['wday'];
// We start on monday (ISO), php getdate() returns 0 (for Sunday) through 6 (for Saturday)
}
if (!is_numeric($hour) || $hour < 1 || $hour > 24) {
$hour = $now['hours'] + ($now['minutes'] < 30 ? 0 : 0.5);
}
if (!is_numeric($duration) || $duration < $min_duration || $duration > $max_duration) {
$duration = 2;
}
$data_search['day'] = $day;
$data_search['hour'] = $hour;
$data_search['duration'] = $duration;
$data_search['assets_version'] = $assets_version;
return $data_search;
}
示例11: datetimetransform
function datetimetransform($input)
{
$todayh = getdate($input);
if ($todayh["seconds"] < 10) {
$todayh["seconds"] = "0" . $todayh["seconds"] . "";
}
if ($todayh["minutes"] < 10) {
$todayh["minutes"] = "0" . $todayh["minutes"] . "";
}
if ($todayh["hours"] < 10) {
$todayh["hours"] = "0" . $todayh["hours"] . "";
}
if ($todayh["mday"] < 10) {
$todayh["mday"] = "0" . $todayh["mday"] . "";
}
if ($todayh["mon"] < 10) {
$todayh["mon"] = "0" . $todayh["mon"] . "";
}
$sec = $todayh[seconds];
$min = $todayh[minutes];
$hours = $todayh[hours];
$d = $todayh[mday];
$m = $todayh[mon];
$y = $todayh[year];
$input = "{$d}-{$m}-{$y} {$hours}:{$min}:{$sec}";
return $input;
}
示例12: esMayorDeEdad
public function esMayorDeEdad($datFecha, $strCampo)
{
$ahora = getdate();
$datCurrentYear = $ahora['year'];
$datHace18anos = $datCurrentYear - 18;
$datMes = $ahora['mon'];
$datDia = $ahora['mday'];
if ($this->esFechaCorta($datFecha, $strCampo)) {
$datFecha = str_replace('-', '/', $datFecha);
$arrFecha = explode('/', $datFecha);
if ($arrFecha[2] < $datHace18anos) {
return $this->esValido;
} elseif ($arrFecha[2] = $datHace18anos && $arrFecha[1] < $datMes) {
return $this->esValido;
} elseif ($arrFecha[2] = $datHace18anos && ($arrFecha[1] = $datMes && $arrFecha[0] <= $datDia)) {
return $this->esValido;
} else {
$this->esValido = false;
$this->error .= '- Lo siento, Debe ser mayor de edad.\\n';
}
} else {
$this->esValido = false;
$this->error .= '- Lo siento, Debe ser mayor de edad.\\n';
}
}
示例13: __construct
public function __construct()
{
$this->aDatos = new aDatos();
$this->idVenta = 0;
$this->total = 0;
$this->fechaRegistro = getdate();
}
示例14: index
function index()
{
$now = getdate();
$year = (int) $now['year'];
$month = (int) $now['mon'];
$this->show($year, $month);
}
示例15: get_setting
/**
* Get the selected time
*
* @return mixed An array containing 'h'=>xx, 'm'=>xx, or null if not set
*/
public function get_setting()
{
$result = $this->config_read($this->name);
$datearr = getdate($result);
$data = array('h' => $datearr['hours'], 'm' => $datearr['minutes'], 'y' => $datearr['year'], 'M' => $datearr['mon'], 'd' => $datearr['mday']);
return $data;
}