/** * Converts date to time on post saving. * * @param array $value Use 'datepicker' to convert to timestamp. * @return int timestamp */ function wpcf_fields_date_value_save_filter($value, $field, $field_object) { if (defined('WPTOOLSET_FORMS_VERSION')) { if (empty($value) || empty($value['datepicker'])) { return false; } if (is_numeric($value['datepicker'])) { $timestamp = $value['datepicker']; } else { $timestamp = wptoolset_strtotime($value['datepicker']); } // Append Hour and Minute if ($timestamp !== false && isset($value['hour']) && isset($value['minute'])) { $timestamp_date = adodb_date('dmY', $timestamp); $date = adodb_mktime(intval($value['hour']), intval($value['minute']), 0, substr($timestamp_date, 2, 2), substr($timestamp_date, 0, 2), substr($timestamp_date, 4, 4)); $timestamp = $date; /* $date = new DateTime( $value['datepicker'] ); try { $date->add( new DateInterval( 'PT' . intval( $value['hour'] ) . 'H' . intval( $value['minute'] ) . 'M' ) ); } catch (Exception $e) { return $timestamp; } $timestamp = $date->format( "U" ); */ } return $timestamp; } // I understand this below is not executed anymore? global $wpcf; // Remove additional meta if any if (isset($field_object->post->ID)) { delete_post_meta($field_object->post->ID, '_wpcf_' . $field_object->cf['id'] . '_hour_and_minute'); } if (empty($value) || empty($value['datepicker'])) { return false; } $value['timestamp'] = wpcf_fields_date_convert_datepicker_to_timestamp($value['datepicker']); if (!wpcf_fields_date_timestamp_is_valid($value['timestamp'])) { $wpcf->debug->errors['date_save_failed'][] = array('value' => $value, 'field' => $field); return false; } // Append Hour and Minute if (isset($value['hour']) && isset($value['minute'])) { $value['timestamp'] = wpcf_fields_date_calculate_time($value); } return $value['timestamp']; }
function dateDiff($fecha1, $fecha2, $type = "D") { // $type puede ser D (dias), M (meses) o A (años).. // Valido los datos.. if ((!isFechaValida($fecha1)) or (!isFechaValida($fecha2))) return false; //Convertimos ambas fechas a su unix timestamp con adodb_mktime.. $tmp = explode("/", $fecha1); $fecha1 = $tmp[1]."/".$tmp[0]."/".$tmp[2]; $time1 = adodb_mktime(0, 0, 0, $tmp[1], $tmp[0], $tmp[2]); $tmp = explode("/", $fecha2); $fecha2 = $tmp[1]."/".$tmp[0]."/".$tmp[2]; $time2 = adodb_mktime(0, 0, 0, $tmp[1], $tmp[0], $tmp[2]); $diferencia = $time2 - $time1; $result = 0; // Ahora ya tengo la cantidad de segundos entre las dos fechas.. // Dividamoslas entre X para obtener ya sean la fecha en años, meses o dias. if ($type == "A") { list($mes1, $dia1, $ano1) = explode("/", $fecha1); list($mes2, $dia2, $ano2) = explode("/", $fecha2); $ano_dif = $ano2 - $ano1; $mes_dif = $mes2 - $mes1; $dia_dif = $dia2 - $dia1; if (($mes_dif < 0) or (($mes_dif == 0) and ($dia_dif < 0))) $ano_dif--; $result = $ano_dif; } if ($type == "M") { $meses = $diferencia / (60 * 60 * 24 * 30); // 30 días como promedio por mes.. $meses = ceil($meses); $result = $meses; } if ($type == "D") { $dias = $diferencia / (60 * 60 * 24); $dias = ceil($dias); $result = $dias; } return $result; }
/** * Returns an ADODB Date timestamp * @return int */ public function getTimestamp($strtime = '') { $strtime = $strtime !== '' ? $strtime : $this->_dtstr; if (self::$isDateTimeSupported) { $dt = new DateTime(is_numeric($strtime) ? "@{$strtime}" : $strtime); $v = $dt->format('U'); } else { if (is_numeric($strtime)) { return $strtime; } else { $d = $strtime && $strtime != 'now' ? $this->parse($strtime) : getdate(); $v = $d ? adodb_mktime($d['hours'], $d['minutes'], $d['seconds'], $d['mon'], $d['mday'], $d['year']) : false; } } return !$v || $v == $strtime ? false : $v; }
/** * Wrapper for adodb_mktime() * Checks if year is zero and returns internal php mktime in that case */ function carl_mktime($hr, $min, $sec, $month = false, $day = false, $year = false, $is_dst = false, $is_gmt = false) { $int_year = intval($year); if ($int_year == 0) { //return mktime($hr,$min,$sec,$month,$day,$year,$is_dst); // $is_dst param is deprecated in php 5 return mktime((int) $hr, (int) $min, (int) $sec, (int) $month, (int) $day); } else { if ($int_year < 100) { // adodb_mktime seems to have a bug where it returns the time plus 1 hour // when year is 2 digits, so we first turn the year into a 4-digit year // before running adodb_mktime $year = carl_date('Y', adodb_mktime(1, 0, 0, 1, 1, $year)); } return adodb_mktime((int) $hr, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year, $is_dst, $is_gmt); } }
/** * Converts a date array to a timestamp * year, month, day are obligatory !! * * @param array $dateArray Date Array * * @return int Timestamp */ public static function arrayToDateTime($dateArray) { $hour = 0; $min = 0; $sec = 0; $dateValid = true; $month = $day = $year = null; if (!empty($dateArray['hours'])) { $hour = $dateArray['hours']; } if (!empty($dateArray['minutes'])) { $min = $dateArray['minutes']; } if (!empty($dateArray['seconds'])) { $sec = $dateArray['seconds']; } if (!empty($dateArray['day'])) { $day = $dateArray['day']; } else { $dateValid = false; } if (!empty($dateArray['month'])) { $month = $dateArray['month']; } else { $dateValid = false; } if (!empty($dateArray['year'])) { $year = $dateArray['year']; } else { $dateValid = false; } if ($dateValid) { return adodb_mktime($hour, $min, $sec, $month, $day, $year); } else { return adodb_mktime(0, 0, 0); } }
public function ts() { return adodb_mktime($this->hour, $this->min, $this->sec, $this->month, $this->day, $this->year); }
include "../../../../include/network.php"; $var = isset($_GET["var"]) ? $_GET["var"] : "gdd50"; $year = isset($_GET["year"]) ? $_GET["year"] : date("Y"); $smonth = isset($_GET["smonth"]) ? $_GET["smonth"] : 5; $sday = isset($_GET["sday"]) ? $_GET["sday"] : 1; $emonth = isset($_GET["emonth"]) ? $_GET["emonth"] : date("m"); $eday = isset($_GET["eday"]) ? $_GET["eday"] : date("d"); $network = isset($_REQUEST["network"]) ? $_REQUEST["network"] : "IACLIMATE"; $nt = new NetworkTable($network); $cities = $nt->table; /** Need to use external date lib * http://php.weblogs.com/adodb_date_time_library */ include "../../../../include/adodb-time.inc.php"; $sts = adodb_mktime(0, 0, 0, $smonth, $sday, $year); $ets = adodb_mktime(0, 0, 0, $emonth, $eday, $year); if ($sts > $ets) { $sts = $ets - 86400; } function mktitlelocal($map, $imgObj, $titlet) { $layer = $map->getLayerByName("credits"); // point feature with text for location $point = ms_newpointobj(); $point->setXY(0, 10); $point->draw($map, $layer, $imgObj, 0, $titlet); } function plotNoData($map, $img) { $layer = $map->getLayerByName("credits"); $point = ms_newpointobj();
function endOfWeek($date) { $viewtime = adodb_mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4)); $weekday = strftime("%w", $viewtime); if ($weekday == 0) { $weekday = 7; } return date("Y-m-d", $viewtime - 86400 * ($weekday - 7)); }
/** * Date select form for Group edit screen. * * @global type $wp_locale * @param type $function * @param type $value * @param type $name * @return string * */ function wpcf_conditional_add_date_controls($function, $value, $name) { global $wp_locale; if ($function == 'date') { $date_parts = explode(',', $value); $time_adj = adodb_mktime(0, 0, 0, $date_parts[1], $date_parts[0], $date_parts[2]); } else { $time_adj = current_time('timestamp'); } $jj = adodb_gmdate('d', $time_adj); $mm = adodb_gmdate('m', $time_adj); $aa = adodb_gmdate('Y', $time_adj); $output = '<div class="wpcf-custom-field-date">' . "\n"; $month = "<select name=\"" . $name . '[month]' . "\" >\n"; for ($i = 1; $i < 13; $i = $i + 1) { $monthnum = zeroise($i, 2); $month .= "\t\t\t" . '<option value="' . $monthnum . '"'; if ($i == $mm) { $month .= ' selected="selected"'; } $month .= '>' . $monthnum . '-' . $wp_locale->get_month_abbrev($wp_locale->get_month($i)) . "</option>\n"; } $month .= '</select>'; $day = '<input name="' . $name . '[date]" type="text" value="' . $jj . '" size="2" maxlength="2" autocomplete="off" />'; $year = '<input name="' . $name . '[year]" type="text" value="' . $aa . '" size="4" maxlength="4" autocomplete="off" />'; $output .= sprintf(__('%1$s%2$s, %3$s'), $month, $day, $year); $output .= '<div class="wpcf_custom_field_invalid_date wpcf-form-error"><p>' . __('Please enter a valid date here', 'wpcf') . '</p></div>' . "\n"; $output .= "</div>\n"; return $output; }
static function UnixTimeStamp($v) { if (is_numeric(substr($v, 0, 1)) && ADODB_PHPVER >= 0x4200) { return parent::UnixTimeStamp($v); } global $ADODB_mssql_mths, $ADODB_mssql_date_order; //Dec 30 2000 12:00AM if ($ADODB_mssql_date_order == 'dmy') { if (!preg_match("|^([0-9]{1,2})[-/\\. ]+([A-Za-z]{3})[-/\\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|", $v, $rr)) { return parent::UnixTimeStamp($v); } if ($rr[3] <= TIMESTAMP_FIRST_YEAR) { return 0; } $theday = $rr[1]; $themth = substr(strtoupper($rr[2]), 0, 3); } else { if (!preg_match("|^([A-Za-z]{3})[-/\\. ]+([0-9]{1,2})[-/\\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|", $v, $rr)) { return parent::UnixTimeStamp($v); } if ($rr[3] <= TIMESTAMP_FIRST_YEAR) { return 0; } $theday = $rr[2]; $themth = substr(strtoupper($rr[1]), 0, 3); } $themth = $ADODB_mssql_mths[$themth]; if ($themth <= 0) { return false; } switch (strtoupper($rr[6])) { case 'P': if ($rr[4] < 12) { $rr[4] += 12; } break; case 'A': if ($rr[4] == 12) { $rr[4] = 0; } break; default: break; } // h-m-s-MM-DD-YY return adodb_mktime($rr[4], $rr[5], 0, $themth, $theday, $rr[3]); }
/** * Also in ADORecordSet. * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format */ function UnixTimeStamp($v) { if (!preg_match("|^([0-9]{4})[-/\\.]?([0-9]{1,2})[-/\\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\\.]{1,4}))?|", $v, $rr)) { return false; } if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2] <= 1) { return 0; } // h-m-s-MM-DD-YY if (!isset($rr[5])) { return adodb_mktime(0, 0, 0, $rr[2], $rr[3], $rr[1]); } return @adodb_mktime($rr[5], $rr[6], $rr[7], $rr[2], $rr[3], $rr[1]); }
function wpv_format_date() { $date_format = $_POST['date-format']; if ($date_format == '') { $date_format = get_option('date_format'); } // this is needed to escape characters in the date_i18n function $date_format = str_replace('\\\\', '\\', $date_format); $date = $_POST['date']; // We can not be sure that the adodb_xxx functions are available, so we do different things whether they exist or not if (defined('ADODB_DATE_VERSION')) { $date = adodb_mktime(0, 0, 0, substr($date, 2, 2), substr($date, 0, 2), substr($date, 4, 4)); echo json_encode(array('display' => adodb_date($date_format, $date), 'timestamp' => $date)); } else { $date = mktime(0, 0, 0, substr($date, 2, 2), substr($date, 0, 2), substr($date, 4, 4)); echo json_encode(array('display' => date_i18n($date_format, intval($date)), 'timestamp' => $date)); } die; }
function mkActiveTime($hr, $min, $sec, $month = false, $day = false, $year = false) { if (function_exists("adodb_mktime")) { return adodb_mktime($hr, $min, $sec, $month, $day, $year); } else { return mktime($hr, $min, $sec, $month, $day, $year); } }
function CreateDateTime($hour, $min, $sec, $month, $day, $year) { if ($this->UseAdodbTime) { return adodb_mktime($hour, $min, $sec, $month, $day, $year); } else { return mktime($hour, $min, $sec, $month, $day, $year); } }
function wpv_filter_parse_date_get_resulting_date($date_value, $format) { $date_value = (string) $date_value; if (!$format && strpos($date_value, ',') !== false) { $date_parts = explode(',', $date_value); $ret = adodb_mktime(0, 0, 0, $date_parts[1], $date_parts[0], $date_parts[2]); return $ret; } else { // just in case the Parser is not loaded yet if (class_exists('Toolset_DateParser') === false) { require_once dirname(__FILE__) . "/expression-parser/parser.php"; } $date_string = trim(trim(str_replace(',', '/', $date_value), "'")); $date = Toolset_DateParser::parseDate($date_string, $format); if (is_object($date) && method_exists($date, 'getTimestamp')) { $timestamp = $date->getTimestamp(); // NOTE this timestamp construction should be compatible with the adodb_xxx functions return $timestamp; } return $date_value; } }
/** * Return a timestamp date built from detailed informations (by default a local PHP server timestamp) * Replace function mktime not available under Windows if year < 1970 * PHP mktime is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows * @param hour Hour (can be -1 for undefined) * @param minute Minute (can be -1 for undefined) * @param second Second (can be -1 for undefined) * @param month Month * @param day Day * @param year Year * @param gm 1=Input informations are GMT values, otherwise local to server TZ * @param check 0=No check on parameters (Can use day 32, etc...) * @param isdst Dayling saving time * @return timestamp Date as a timestamp, '' if error * @see dol_print_date, dol_stringtotime */ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $check = 1, $isdst = true) { //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; // Clean parameters if ($hour == -1) { $hour = 0; } if ($minute == -1) { $minute = 0; } if ($second == -1) { $second = 0; } // Check parameters if ($check) { if (!$month || !$day) { return ''; } if ($day > 31) { return ''; } if ($month > 12) { return ''; } if ($hour < 0 || $hour > 24) { return ''; } if ($minute < 0 || $minute > 60) { return ''; } if ($second < 0 || $second > 60) { return ''; } } $usealternatemethod = false; if ($year <= 1970) { $usealternatemethod = true; } // <= 1970 if ($year >= 2038) { $usealternatemethod = true; } // >= 2038 if ($usealternatemethod || $gm) { /* // On peut utiliser strtotime pour obtenir la traduction. // strtotime is ok for range: Friday 13 December 1901 20:45:54 GMT to Tuesday 19 January 2038 03:14:07 GMT. $montharray=array(1=>'january',2=>'february',3=>'march',4=>'april',5=>'may',6=>'june', 7=>'july',8=>'august',9=>'september',10=>'october',11=>'november',12=>'december'); $string=$day." ".$montharray[0+$month]." ".$year." ".$hour.":".$minute.":".$second." GMT"; $date=strtotime($string); print "- ".$string." ".$date." -"; */ $date = adodb_mktime($hour, $minute, $second, $month, $day, $year, $isdst, $gm); } else { $date = mktime($hour, $minute, $second, $month, $day, $year); } return $date; }
function _makeTimestamp($str) { $d = $str && $str != 'now' ? $this->parse($str) : getdate(); return adodb_mktime($d['hours'], $d['minutes'], $d['seconds'], $d['mon'], $d['mday'], $d['year']); }
/** * Calendar view. * * @global object $wpdb * @global type $m * @global type $wp_locale * @global type $actors * @param type $params * @param type $initial * @param type $echo * @return type */ function wpcf_fields_date_get_calendar($params, $initial = true, $echo = true) { global $wpdb, $m, $wp_locale, $actors; // wpcf Set our own date $monthnum = adodb_date('n', $params['field_value']); $year = adodb_date('Y', $params['field_value']); $wpcf_date = adodb_date('j', $params['field_value']); $cache = array(); $key = md5($params['field']['slug'] . $wpcf_date); if ($cache = wp_cache_get('get_calendar', 'calendar')) { if (is_array($cache) && isset($cache[$key])) { if ($echo) { echo apply_filters('get_calendar', $cache[$key]); return; } else { return apply_filters('get_calendar', $cache[$key]); } } } if (!is_array($cache)) { $cache = array(); } if (isset($_GET['w'])) { $w = '' . intval($_GET['w']); } // week_begins = 0 stands for Sunday $week_begins = intval(get_option('start_of_week')); // Let's figure out when we are if (!empty($monthnum) && !empty($year)) { $thismonth = '' . zeroise(intval($monthnum), 2); $thisyear = '' . intval($year); } elseif (!empty($w)) { // We need to get the month from MySQL $thisyear = '' . intval(substr($m, 0, 4)); $d = ($w - 1) * 7 + 6; //it seems MySQL's weeks disagree with PHP's $thismonth = $wpdb->get_var($wpdb->prepare("SELECT DATE_FORMAT((DATE_ADD(%s, INTERVAL %d DAY) ), '%%m')", sprintf('%d0101', $thisyear), $d)); } elseif (!empty($m)) { $thisyear = '' . intval(substr($m, 0, 4)); if (strlen($m) < 6) { $thismonth = '01'; } else { $thismonth = '' . zeroise(intval(substr($m, 4, 2)), 2); } } else { $thisyear = adodb_gmdate('Y', current_time('timestamp')); $thismonth = adodb_gmdate('m', current_time('timestamp')); } $unixmonth = adodb_mktime(0, 0, 0, $thismonth, 1, $thisyear); $last_day = adodb_date('t', $unixmonth); $class = !empty($params['class']) ? ' class="' . $params['class'] . '"' : ''; /* translators: Calendar caption: 1: month name, 2: 4-digit year */ $calendar_caption = _x('%1$s %2$s', 'calendar caption'); $calendar_output = '<table id="wp-calendar-' . md5(serialize(func_get_args())) . '" summary="' . esc_attr__('Calendar') . '"' . $class . '> <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), adodb_date('Y', $unixmonth)) . '</caption> <thead> <tr>'; $myweek = array(); for ($wdcount = 0; $wdcount <= 6; $wdcount++) { $myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7); } foreach ($myweek as $wd) { $day_name = true == $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); $wd = esc_attr($wd); $calendar_output .= "\n\t\t<th scope=\"col\" title=\"{$wd}\">{$day_name}</th>"; } $calendar_output .= ' </tr> </thead> <tfoot> <tr>'; $calendar_output .= ' </tr> </tfoot> <tbody> <tr>'; // See how much we should pad in the beginning $pad = calendar_week_mod(adodb_date('w', $unixmonth) - $week_begins); if (0 != $pad) { $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad"> </td>'; } $daysinmonth = intval(adodb_date('t', $unixmonth)); for ($day = 1; $day <= $daysinmonth; ++$day) { if (isset($newrow) && $newrow) { $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t"; } $newrow = false; if ($day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp'))) { $calendar_output .= '<td id="today">'; } else { $calendar_output .= '<td>'; } // wpcf if ($wpcf_date == $day) { $calendar_output .= '<a href="javascript:void(0);">' . $day . '</a>'; } else { $calendar_output .= $day; } $calendar_output .= '</td>'; if (6 == calendar_week_mod(adodb_date('w', adodb_mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) { $newrow = true; } } $pad = 7 - calendar_week_mod(adodb_date('w', adodb_mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins); if ($pad != 0 && $pad != 7) { $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '"> </td>'; } $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>"; $cache[$key] = $calendar_output; wp_cache_set('get_calendar', $cache, 'calendar'); if ($echo) { echo apply_filters('get_calendar', $calendar_output); } else { return apply_filters('get_calendar', $calendar_output); } }
/** * Gets a timestamp for input date provided in one of this formats: "year-month-day hour:min:sec", "year-month-day", "hour:min:sec" */ function getTimestamp($iso_date_or_hour = null) { if (empty($iso_date_or_hour)) { return Ak::time(); } if (!preg_match("/^\n ([0-9]{4})[-\\/\\.]? # year\n ([0-9]{1,2})[-\\/\\.]? # month\n ([0-9]{1,2})[ -]? # day\n (\n ([0-9]{1,2}):? # hour\n ([0-9]{2}):? # minute\n ([0-9\\.]{0,4}) # seconds\n )?/x", $iso_date_or_hour, $rr)) { if (preg_match("|^(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\\.]{1,4}))?|", $iso_date_or_hour, $rr)) { return empty($rr[0]) ? Ak::time() : mktime($rr[2], $rr[3], $rr[4]); } } else { if ($rr[1] >= 2038 || $rr[1] <= 1970) { require_once AK_CONTRIB_DIR . DS . 'adodb' . DS . 'adodb-time.inc.php'; return isset($rr[5]) ? adodb_mktime($rr[5], $rr[6], (int) $rr[7], $rr[2], $rr[3], $rr[1]) : adodb_mktime(0, 0, 0, $rr[2], $rr[3], $rr[1]); } else { return isset($rr[5]) ? mktime($rr[5], $rr[6], (int) $rr[7], $rr[2], $rr[3], $rr[1]) : mktime(0, 0, 0, $rr[2], $rr[3], $rr[1]); } } trigger_error(Ak::t('Invalid ISO date. You must supply date in one of the following formats: "year-month-day hour:min:sec", "year-month-day", "hour:min:sec"')); return false; }
function formatDate($value) { if (!is_numeric($value)) { $v = str2date($value); if (!is_null($v)) { $value = $v; } else { return $this->stdFormat($value); } } if (is_numeric($value)) { $dateParts = adodb_getdate($value); //speed: adodb_getdate is slow!!! $year = $dateParts['year']; $month = $dateParts['mon']; $day = $dateParts['mday']; $hour = $dateParts['hours']; $min = $dateParts['minutes']; $secs = $dateParts['seconds']; $dow = $dateParts['wday']; } $_day_power = 86400; $_hour_power = 3600; $_min_power = 60; //cannot replace Epoch by constant, because value of adodb_mktime depends on time zone //but we compute it only once .... static $_MicrosoftEpoch; //speed: cache $epoch (1.5sec) if (!$_MicrosoftEpoch) { $_MicrosoftEpoch = adodb_mktime(0, 0, 0, 12, 30, 1899); } if (sizeof($this->formatParts) == 1) { $fmt = $this->formatParts[0]; } elseif ($value == $_MicrosoftEpoch) { if ($this->formatParts[2]) { $fmt = $this->formatParts[2]; } else { $fmt = $this->formatParts[0]; } } elseif (is_null($value)) { $fmt = $this->formatParts[3]; } else { $fmt = $this->formatParts[0]; } $res = ''; if (!isset($fmt)) { if (is_null($value)) { return ''; } else { if ($year == 1899 && $month == 12 && ($day = 30)) { if ($hour == 0 && $min == 0 && $sec == 0) { return null; } else { return format($value, 'long time'); } } else { if ($hour == 0 && $min == 0 && $sec == 0) { return format($value, 'short date'); } else { return format($value, 'general date'); } } } } foreach ($fmt as $fmtItem) { switch ($fmtItem['token']) { case $this->STRING: $res .= $fmtItem['value']; break; case 'd': $res .= $day; $this->OnDayFormat(); break; case 'dd': $res .= $this->twoDigits($day); $this->OnDayFormat(); break; case 'ddd': $res .= strftime('%a', $_day_power * (3 + $dow)); break; case 'dddd': $res .= strftime('%A', $_day_power * (3 + $dow)); break; case 'ddddd': $res .= format($value, 'short date'); break; case 'dddddd': $res .= format($value, 'long date'); break; case 'm': $res .= $month; $this->OnMonthFormat(); break; case 'mm': $res .= $this->twoDigits($month); $this->OnMonthFormat(); break; case 'mmm': $res .= strftime('%b', mktime(0, 0, 0, $month, 2, 1971)); $this->OnMonthFormat(); break; case 'mmmm': $res .= strftime('%B', mktime(0, 0, 0, $month, 2, 1971)); $this->OnMonthFormat(); break; case 'y': $res .= $dateParts['yday'] + 1; break; case 'yy': $y = $year % 100; $res .= $this->twoDigits($y); break; case 'yyyy': $res .= $year; break; case 'h': $res .= $hour; break; case 'hh': $res .= $this->twoDigits($hour); break; case 'n': $res .= $min; break; case 'nn': $res .= $this->twoDigits($min); break; case 's': $res .= $secs; break; case 'ss': $res .= $this->twoDigits($secs); break; case 'ttttt': $res .= format($value, 'long time'); break; case '/': $res .= $this->getDateSep(); break; default: $res .= $fmtItem['value']; } } return $res; }
</td> <td class="main" width="70%"><?php echo osc_draw_input_field('lastname', isset($Qaccount) ? $Qaccount->value('customers_lastname') : '', '', true); ?> </td> </tr> <?php if (ACCOUNT_DATE_OF_BIRTH > -1) { ?> <tr> <td class="main" width="30%"><?php echo ENTRY_DATE_OF_BIRTH; ?> </td> <td class="main" width="70%"><?php echo tep_draw_date_pull_down_menu('dob', isset($Qaccount) ? adodb_mktime(0, 0, 0, $Qaccount->valueInt('customers_dob_month'), $Qaccount->valueInt('customers_dob_day'), $Qaccount->valueInt('customers_dob_year')) : '', false, true, true, date('Y') - 1901, -5) . ' <span class="inputRequirement">*</span>'; ?> </td> </tr> <?php } ?> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?> </td> </tr> <tr> <td class="main" width="30%"><?php echo ENTRY_EMAIL_ADDRESS;
/** Returns a timestamp given a GMT/UTC time. Note that $is_dst is not implemented and is ignored. */ function adodb_gmmktime($hr, $min, $sec, $mon = false, $day = false, $year = false, $is_dst = false) { return adodb_mktime($hr, $min, $sec, $mon, $day, $year, $is_dst, true); }
<?php include_once '../adodb-time.inc.php'; //adodb_date_test(); //require("adodb-time.inc.php"); echo adodb_date('d/m/Y', adodb_mktime(0, 0, 0, 12, 1, 2056)); $datestring = "1963-12-04"; // string normally from mySQL $stringArray = explode("-", $datestring); $date = adodb_mktime(0, 0, 0, $stringArray[1], $stringArray[2], $stringArray[0]); $convertedDate = date("d-M-Y", $date); // converted string to UK style date echo "Birthday: {$convertedDate}"; //why is string returned as one day (3 not 4) less for this example??
function putcalendar($m1 = 0, $m2 = 0) { //Возвращает календарь на месяцы [$m1,$m2] года $selectedyear if ($m1 == 0) { $m1 = $this->nmon; } if ($m2 == 0) { $m2 = $this->nmon; } if ($m1 > $m2) { $a = $m1; $m1 = $m2; $m2 = $a; } $tabcol = $this->maintabcolumns; if ($m1 == $m2) { $tabcol = 1; } $text = ""; //$text="\n".'<table border="0" cellspacing="'.$this->maincellspacing.'" cellpadding="'.$this->maincellpadding.'"><tr>'; $rows = 0; $cols = 0; for ($z = $m1; $z <= $m2; $z++) { $mon = $z; //Если форма не выводилась - selectedyear ставили в конструкторе $year = $this->selectedyear; $daysamount = $this->dayscount[$z - 1] + 1; if ($this->leapyear($year) and $z == 2) { $daysamount++; } $tt = adodb_mktime(0, 0, 0, $mon, 0, (int) $year); $firstday = date('w', $tt); //0-6 $text .= '<td align="center" valign="top">'; $cols++; $text .= $this->drawverticalmonth($firstday, $mon, $year, $daysamount); $text .= '</td>'; } if ($rows > 0 and $cols < $tabcol) { //Дорисовать недостающие ячейки строки $voids = $tabcol - $cols; for ($i = 0; $i < $voids; $i++) { $text .= '<td><font size="' . $this->daysize . '"> </font></td>'; } } return $text; //.'</tr></table>'; }
static function UnixTimeStamp($v) { global $ADODB_sybase_mths; //11.02.2001 Toni Tunkkari toni.tunkkari@finebyte.com //Changed [0-9] to [0-9 ] in day conversion if (!preg_match("/([A-Za-z]{3})[-/\\. ]([0-9 ]{1,2})[-/\\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})/", $v, $rr)) { return parent::UnixTimeStamp($v); } if ($rr[3] <= TIMESTAMP_FIRST_YEAR) { return 0; } $themth = substr(strtoupper($rr[1]), 0, 3); $themth = $ADODB_sybase_mths[$themth]; if ($themth <= 0) { return false; } switch (strtoupper($rr[6])) { case 'P': if ($rr[4] < 12) { $rr[4] += 12; } break; case 'A': if ($rr[4] == 12) { $rr[4] = 0; } break; default: break; } // h-m-s-MM-DD-YY return adodb_mktime($rr[4], $rr[5], 0, $themth, $rr[2], $rr[3]); }
public function wpt_localize_extended_date() { if (!isset($_POST['date'])) { die; } $date = $_POST['date']; $date_format = ''; if (isset($_POST['date-format'])) { $date_format = $_POST['date-format']; } if ($date_format == '') { $date_format = get_option('date_format'); } $date = adodb_mktime(0, 0, 0, substr($date, 2, 2), substr($date, 0, 2), substr($date, 4, 4)); $date_format = str_replace('\\\\', '\\', $date_format); echo json_encode(array('display' => adodb_date($date_format, $date), 'timestamp' => $date)); die; }
$awaydate = my_date($mybb->settings['dateformat'], $memprofile['awaydate']); if (!empty($memprofile['awayreason'])) { $reason = $parser->parse_badwords($memprofile['awayreason']); $awayreason = htmlspecialchars_uni($reason); } else { $awayreason = $lang->away_no_reason; } if ($memprofile['returndate'] == '') { $returndate = "{$lang->unknown}"; } else { $returnhome = explode("-", $memprofile['returndate']); // PHP native date functions use integers so timestamps for years after 2038 will not work // Thus we use adodb_mktime if ($returnhome[2] >= 2038) { require_once MYBB_ROOT . "inc/functions_time.php"; $returnmkdate = adodb_mktime(0, 0, 0, $returnhome[1], $returnhome[0], $returnhome[2]); $returndate = my_date($mybb->settings['dateformat'], $returnmkdate, "", 1, true); } else { $returnmkdate = mktime(0, 0, 0, $returnhome[1], $returnhome[0], $returnhome[2]); $returndate = my_date($mybb->settings['dateformat'], $returnmkdate); } // If our away time has expired already, we should be back, right? if ($returnmkdate < TIME_NOW) { $db->update_query('users', array('away' => '0', 'awaydate' => '0', 'returndate' => '', 'awayreason' => ''), 'uid=\'' . (int) $memprofile['uid'] . '\''); // Update our status to "not away" $memprofile['away'] = 0; } } // Check if our away status is set to 1, it may have been updated already (see a few lines above) if ($memprofile['away'] == 1) { eval("\$awaybit = \"" . $templates->get("member_profile_away") . "\";");
if (!isset($_POST['gender']) || $_POST['gender'] != 'm' && $_POST['gender'] != 'f') { $osC_MessageStack->add('header', ENTRY_GENDER_ERROR, 'error'); $error = true; } } if (!isset($_POST['firstname']) || strlen(trim($_POST['firstname'])) < ACCOUNT_FIRST_NAME) { $osC_MessageStack->add('header', ENTRY_FIRST_NAME_ERROR, 'error'); $error = true; } if (!isset($_POST['lastname']) || strlen(trim($_POST['lastname'])) < ACCOUNT_LAST_NAME) { $osC_MessageStack->add('header', ENTRY_LAST_NAME_ERROR, 'error'); $error = true; } if (ACCOUNT_DATE_OF_BIRTH > -1) { if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && checkdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) { $dob = adodb_mktime(0, 0, 0, $_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years']); } else { $osC_MessageStack->add('header', ENTRY_DATE_OF_BIRTH_ERROR, 'error'); $error = true; } } if (!isset($_POST['email_address']) || strlen(trim($_POST['email_address'])) < ACCOUNT_EMAIL_ADDRESS) { $osC_MessageStack->add('header', ENTRY_EMAIL_ADDRESS_ERROR, 'error'); $error = true; } elseif (tep_validate_email($_POST['email_address']) == false) { $osC_MessageStack->add('header', ENTRY_EMAIL_ADDRESS_CHECK_ERROR, 'error'); $error = true; } else { $Qcheck = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address'); if (isset($_GET['cID']) && is_numeric($_GET['cID'])) { $Qcheck->appendQuery('and customers_id != :customers_id');
/** * Also in ADORecordSet. * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format */ function UnixTimeStamp($v) { if (is_object($v)) { // odbtp support //( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 ) return adodb_mktime($v->hour, $v->minute, $v->second, $v->month, $v->day, $v->year); } if (!preg_match("|^([0-9]{4})[-/\\.]?([0-9]{1,2})[-/\\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\\.]{1,4}))?|", $v, $rr)) { return false; } if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2] <= 1) { return 0; } // h-m-s-MM-DD-YY if (!isset($rr[5])) { return adodb_mktime(0, 0, 0, $rr[2], $rr[3], $rr[1]); } return @adodb_mktime($rr[5], $rr[6], $rr[7], $rr[2], $rr[3], $rr[1]); }
public function cred_post_expiration_date() { $date_format = $_POST['date-format']; if ($date_format == '') { $date_format = get_option('date_format'); } $date = $_POST['date']; $date = adodb_mktime(0, 0, 0, substr($date, 2, 2), substr($date, 0, 2), substr($date, 4, 4)); $date_format = str_replace('\\\\', '\\', $date_format); echo json_encode(array('display' => adodb_date($date_format, $date), 'timestamp' => $date)); die; }