public function display_tpotm($event) { $now = time(); $date_today = gmdate("Y-m-d", $now); list($year_cur, $month_cur, $day1) = split('-', $date_today); // Start time for current month $month_start_cur = gmmktime(0, 0, 0, $month_cur, 1, $year_cur); $month_start = $month_start_cur; $month_end = $now; // group_id 5 = administrators // group_id 4 = global moderators // this groups belong to a Vanilla 3.1.x board $sql = 'SELECT u.username, u.user_id, u.user_colour, u.user_type, u.group_id, COUNT(p.post_id) AS total_posts FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . ' p WHERE u.user_id > ' . ANONYMOUS . ' AND u.user_id = p.poster_id AND p.post_time BETWEEN ' . $month_start . ' AND ' . $month_end . ' AND (u.user_type <> ' . USER_FOUNDER . ') AND (u.group_id <> 5) AND (u.group_id <> 4) GROUP BY u.user_id ORDER BY total_posts DESC'; $result = $this->db->sql_query_limit($sql, 1); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); // let's go then.. // posts made into the selected elapsed time $topm_tp = $row['total_posts']; $topm_un = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); // there is not a Top Poster, usually happens with fresh installations, where only the FOUNDER made the first post/topic. Or no normal users already did it. //Here TOPM_UN reflects this state. $this->template->assign_vars(array('TOPM_UN' => $topm_tp < 1 ? $topm_un = $this->user->lang['TOP_USERNAME_NONE'] : $topm_un, 'L_TPOTM' => $this->user->lang['TOP_CAT'], 'L_TOPM_UNA_L' => $this->user->lang['TOP_USERNAME'], 'L_TOPM_UPO_L' => sprintf($this->user->lang['TOP_USER_MONTH_POSTS'], $topm_tp), 'L_TOPM_POSTS_L' => $topm_tp > 1 || $topm_tp == 0 ? $this->user->lang['TOP_POSTS'] : $this->user->lang['TOP_POST'])); }
function post_notification_mysql2gmdate($mysqlstring) { if (empty($mysqlstring)) { return false; } return gmmktime((int) substr($mysqlstring, 11, 2), (int) substr($mysqlstring, 14, 2), (int) substr($mysqlstring, 17, 2), (int) substr($mysqlstring, 5, 2), (int) substr($mysqlstring, 8, 2), (int) substr($mysqlstring, 0, 4)); }
/** * Builds the query for this datagrid * * @return array An array with two arguments containing the query and its parameters. */ private function buildQuery() { $parameters = array($this->id); // start query, as you can see this query is build in the wrong place, // because of the filter it is a special case // wherein we allow the query to be in the actionfile itself $query = 'SELECT i.id, UNIX_TIMESTAMP(i.sent_on) AS sent_on FROM forms_data AS i WHERE i.form_id = ?'; // add start date if ($this->filter['start_date'] !== '') { // explode date parts $chunks = explode('/', $this->filter['start_date']); // add condition $query .= ' AND i.sent_on >= ?'; $parameters[] = BackendModel::getUTCDate(null, gmmktime(23, 59, 59, $chunks[1], $chunks[0], $chunks[2])); } // add end date if ($this->filter['end_date'] !== '') { // explode date parts $chunks = explode('/', $this->filter['end_date']); // add condition $query .= ' AND i.sent_on <= ?'; $parameters[] = BackendModel::getUTCDate(null, gmmktime(23, 59, 59, $chunks[1], $chunks[0], $chunks[2])); } // new query return array($query, $parameters); }
/** * Set the time * @access protected This class is immutable, so this is protected. Only the constructor calls it. */ protected function setTime($hour = null, $minute = null, $second = null, $rollover = null) { if (is_null($hour)) { $hour = gmdate("H"); } if (is_null($minute)) { $minute = gmdate("i"); } if (is_null($second)) { $second = gmdate("s"); } if (is_null($rollover)) { $rollover = false; } if (!$rollover) { if ($hour > 23 || $minute > 59 || $second > 59) { throw new qCal_DateTime_Exception_InvalidTime(sprintf("Invalid time specified for qCal_Time: \"%02d:%02d:%02d\"", $hour, $minute, $second)); } } // since PHP is incapable of storing a time without a date, we use the first day of // the unix epoch so that we only have the amount of seconds since the zero of unix epoch // we only use gm here because we don't want the server's timezone to interfere $time = gmmktime($hour, $minute, $second, 1, 1, 1970); $this->time = $time; $formatString = "a|A|B|g|G|h|H|i|s|u"; $keys = explode("|", $formatString); $vals = explode("|", gmdate($formatString, $this->getTimestamp(false))); $this->timeArray = array_merge($this->timeArray, array_combine($keys, $vals)); return $this; }
/** * This method parses branches even though RCS doesn't support * branches. But rlog from the RCS tools supports them, and displays them * even on RCS repositories. */ protected function _init() { $raw = $this->_file->getAccum(); /* Initialise a simple state machine to parse the output of rlog */ $state = 'init'; while (!empty($raw) && $state != 'done') { switch ($state) { /* Found filename, now looking for the revision number */ case 'init': $line = array_shift($raw); if (preg_match("/revision (.+)\$/", $line, $parts)) { $this->_rev = $parts[1]; $state = 'date'; } break; /* Found revision and filename, now looking for date */ /* Found revision and filename, now looking for date */ case 'date': $line = array_shift($raw); if (preg_match("|^date:\\s+(\\d+)[-/](\\d+)[-/](\\d+)\\s+(\\d+):(\\d+):(\\d+).*?;\\s+author:\\s+(.+);\\s+state:\\s+(\\S+);(\\s+lines:\\s+\\+(\\d+)\\s\\-(\\d+))?|", $line, $parts)) { $this->_date = gmmktime($parts[4], $parts[5], $parts[6], $parts[2], $parts[3], $parts[1]); $this->_author = $parts[7]; $this->_state = $parts[8]; if (isset($parts[9])) { $this->_lines = '+' . $parts[10] . ' -' . $parts[11]; $this->_files[$this->_file->getSourcerootPath()] = array('added' => $parts[10], 'deleted' => $parts[11]); } $state = 'branches'; } break; /* Look for a branch point here - format is 'branches: * x.y.z; a.b.c;' */ /* Look for a branch point here - format is 'branches: * x.y.z; a.b.c;' */ case 'branches': /* If we find a branch tag, process and pop it, otherwise leave input stream untouched */ if (!empty($raw) && preg_match("/^branches:\\s+(.*)/", $raw[0], $br)) { /* Get the list of branches from the string, and * push valid revisions into the branches array */ $brs = preg_split('/;\\s*/', $br[1]); foreach ($brs as $brpoint) { if ($this->_rep->isValidRevision($brpoint)) { $this->_branches[] = $brpoint; } } array_shift($raw); } $state = 'done'; break; } } /* Assume the rest of the lines are the log message */ $this->_log = implode("\n", $raw); $this->_tags = $this->_file->getRevisionSymbol($this->_rev); $this->_setSymbolicBranches(); $branches = $this->_file->getBranches(); $key = array_keys($branches, $this->_rev); $this->_branch = empty($key) ? array_keys($branches, $this->_rep->strip($this->_rev, 1)) : $key; }
function xfac_sync_mysqlDateToGmtTimestamp($string) { if (preg_match('/^(\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)$/', trim($string), $m)) { return gmmktime($m[4], $m[5], $m[6], $m[2], $m[3], $m[1]); } return 0; }
/** * Initiate current time list. * * @param Ai1ec_Registry_Object $registry * * @return void */ public function __construct(Ai1ec_Registry_Object $registry) { parent::__construct($registry); $gmt_time = version_compare(PHP_VERSION, '5.1.0') >= 0 ? time() : gmmktime(); $this->_current_time = array((int) $_SERVER['REQUEST_TIME'], $gmt_time); $this->_gmtdates = $registry->get('cache.memory'); }
public static function getDefaultFileName($time = null) { if (empty($time)) { $time = gmmktime(); } return self::$filePrefix . gmdate('d_M_Y-H_i_s-T', $time) . '.zip'; }
function smarty_modifier_nicetime($string) { if (ereg('(19|20[0-9]{2})[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01]) ([012 ][0-9])[: .]([0-5][0-9])[: .]([0-5][0-9])[ \\.].*', $string, $regs)) { $unixtime = gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); $time = time() + 28800 - $unixtime; if ($time < 24 * 3600 * 5) { if ($time < 48 * 3600) { if ($time < 24 * 3600) { if ($time < 5 * 3600) { if ($time < 3600) { if ($time < 60) { return $time . '秒前'; } else { return floor($time / 60) . '分钟前'; } } else { $min = floor($time % 3600 / 60); return floor($time / 3600) . '小时' . ($min > 0 ? $min . '分钟' : '') . '前'; } } else { return '今天 ' . $regs[4] . ':' . $regs[5] . ':' . $regs[6]; } } else { return '昨天'; } } else { return floor($time / (24 * 3600)) . '天前'; } } else { return $string; } } else { return $string; } }
function wp_days_ago($mode = 0, $prepend = "", $append = "", $texts = array("Today", "Yesterday", "One week ago", "days ago", "year", "years", "ago", "day ago", "days ago", "Just now", "One minute ago", "minutes ago", "1 hour ago", "hours ago", "Some time in the future")) { $days = round((strtotime(date("Y-m-d", gmmktime() + get_option('gmt_offset') * 3600)) - strtotime(date("Y-m-d", get_the_time("U")))) / 86400); $minutes = round((strtotime(date("Y-m-d H:i", gmmktime() + get_option('gmt_offset') * 3600)) - strtotime(date("Y-m-d H:i", get_the_time("U")))) / 60); $output = $prepend; if ($minutes < 0) { $output .= $texts[14]; } else { if ($mode == 0 && $minutes < 1440) { if ($minutes == 0) { $output .= $texts[9]; } else { if ($minutes == 1) { $output .= $texts[10]; } else { if ($minutes < 60) { $output .= $minutes . " " . $texts[11]; } else { if ($minutes < 120) { $output .= $texts[12]; } else { $output .= floor($minutes / 60) . " " . $texts[13]; } } } } } else { if ($days == 0) { $output = $output . $texts[0]; } elseif ($days == 1) { $output = $output . $texts[1]; } elseif ($days == 7) { $output = $output . $texts[2]; } else { $years = floor($days / 365); if ($years > 0) { if ($years == 1) { $yearappend = $texts[4]; } else { $yearappend = $texts[5]; } $days = $days - 365 * $years; if ($days == 0) { $output = $output . $years . " " . $yearappend . " " . $texts[6]; } else { if ($days == 1) { $output = $output . $years . " " . $yearappend . ", " . $days . " " . $texts[7]; } else { $output = $output . $years . " " . $yearappend . ", " . $days . " " . $texts[8]; } } } else { $output = $output . $days . " " . $texts[3]; } } } } $output = $output . $append; echo $output; }
protected function run_gmgetdate_assertion() { $expected = time(); $date_array = phpbb_gmgetdate($expected); $actual = gmmktime($date_array['hours'], $date_array['minutes'], $date_array['seconds'], $date_array['mon'], $date_array['mday'], $date_array['year']); $this->assertEquals($expected, $actual); }
function _createElements() { $this->_elements = array(); for ($i = 1; $i <= 31; $i++) { $days[$i] = $i; } for ($i = 1; $i <= 12; $i++) { $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B"); } for ($i = $this->_options['startyear']; $i <= $this->_options['stopyear']; $i++) { $years[$i] = $i; } $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes(), true); $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes(), true); $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes(), true); // If optional we add a checkbox which the user can use to turn if on if ($this->_options['optional']) { $this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'off', null, get_string('disable'), $this->getAttributes(), true); } foreach ($this->_elements as $element) { if (method_exists($element, 'setHiddenLabel')) { $element->setHiddenLabel(true); } } }
function ewiki_decode_datetime($str, $localize = 1, $gmt = 0) { $done = 0; $months = array_flip(array("Err", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")); #-- 8601 if ($str[4] == "-" and preg_match("/(\\d+)-(\\d+)-(\\d+)(T(\\d+):(\\d+)(:(\\d+))?)?/", $str, $uu)) { $t = gmmktime($uu[5], $uu[6], $uu[8], $uu[2], $uu[3], $uu[1]); } elseif ($str[3] == " " and preg_match("/\\w+ (\\w+) +(\\d+) (\\d+):(\\d+):(\\d+) (\\d+)/", $str, $uu)) { $t = gmmktime($uu[3], $uu[4], $uu[5], $months[$uu[1]], $uu[2], $uu[6]); $gmt = 1; } elseif (1 and preg_match("/\\w+, (\\d+)[- ](\\w+)[- ](\\d+) (\\d+):(\\d+):(\\d+)/", $str, $uu)) { $t = gmmktime($uu[4], $uu[5], $uu[6], $months[$uu[2]], $uu[1], $uu[3]); $gmt = 1; } elseif ((int) $str == $str) { $t = (int) $str; $gmt = 1; } else { $t = strtotime($str); $gmt = 1; } #-- is local time (iso8601 only) if (!$gmt && $localize && preg_match('/([+-])(\\d+):(\\d+)$/', $str, $uu)) { $dt = $uu[1] * 60 + $uu[2]; if ($uu[1] == "+") { $t -= $dt; } else { $t += $dt; } } return $t; }
static function number2Ts($dateValue = 0, $base = 'win') { if ($base == 'win') { // Base date of 1st Jan 1900 = 1.0 $myExcelBaseDate = 25569; // Adjust for the spurious 29-Feb-1900 (Day 60) if ($dateValue < 60) { --$myExcelBaseDate; } } else { // Base date of 2nd Jan 1904 = 1.0 $myExcelBaseDate = 24107; } // Perform conversion if ($dateValue >= 1) { $utcDays = $dateValue - $myExcelBaseDate; $returnValue = round($utcDays * 24 * 60 * 60); if ($returnValue <= PHP_INT_MAX && $returnValue >= -PHP_INT_MAX) { $returnValue = (int) $returnValue; } } else { $hours = round($dateValue * 24); $mins = round($dateValue * 24 * 60) - round($hours * 60); $secs = round($dateValue * 24 * 60 * 60) - round($hours * 60 * 60) - round($mins * 60); $returnValue = (int) gmmktime($hours, $mins, $secs); } // Return return $returnValue; }
public static function createEmail($id = '', $override = array()) { global $timedate; $time = mt_rand(); $name = 'SugarEmail'; $email = new Email(); $email->name = $name . $time; $email->type = 'out'; $email->status = 'sent'; $email->date_sent = $timedate->to_display_date_time(gmdate("Y-m-d H:i:s", gmmktime() - 3600 * 24 * 2)); // Two days ago if (!empty($id)) { $email->new_with_id = true; $email->id = $id; } foreach ($override as $key => $value) { $email->{$key} = $value; } $email->save(); if (!empty($override['parent_id']) && !empty($override['parent_type'])) { self::createEmailsBeansRelationship($email->id, $override['parent_type'], $override['parent_id']); } self::$_createdEmails[] = $email; return $email; }
function Auth_OpenID_splitNonce($nonce_string) { // Extract a timestamp from the given nonce string $result = preg_match(Auth_OpenID_Nonce_REGEX, $nonce_string, $matches); if ($result != 1 || count($matches) != 8) { return null; } list($unused, $tm_year, $tm_mon, $tm_mday, $tm_hour, $tm_min, $tm_sec, $uniquifier) = $matches; $timestamp = @gmmktime($tm_hour, $tm_min, $tm_sec, $tm_mon, $tm_mday, $tm_year); if ($timestamp === false || $timestamp < 0) { return null; } return array($timestamp, $uniquifier); }
function mycal_build_calendar($year, $month, $day, $events = array()) { $prevnext = array('«' => '/event/calendar/' . _mycal_format_date($year, $month - 1), '»' => '/event/calendar/' . _mycal_format_date($year, $month + 1)); $first_day = 0; // First day is Sunday $first_of_month = gmmktime(0, 0, 0, $month, 1, $year); $day_names = array(); // January 4, 1970 was a Sunday for ($n = 0, $t = (3 + $first_day) * 86400; $n < 7; $n++, $t += 86400) { $day_names[$n] = ucfirst(gmstrftime('%A', $t)); #%A means full textual day name } list($month, $year, $month_name, $weekday) = explode(',', gmstrftime('%m,%Y,%B,%w', $first_of_month)); $weekday = ($weekday + 7 - $first_day) % 7; // Adjust for $first_day $title = htmlentities(ucfirst($month_name)) . ' ' . $year; @(list($p, $pl) = each($prevnext)); @(list($n, $nl) = each($prevnext)); $p = '<a class="calendar-prev" href="' . htmlspecialchars($pl) . '">' . $p . '</a>'; $n = '<a class="calendar-next" href="' . htmlspecialchars($nl) . '">' . $n . '</a>'; $calendar = '<table class="calendar" summary="">' . "\n"; $calendar .= '<caption class="calendar-month">' . $p . '<a href="/event/calendar/' . _mycal_format_date($year, $month) . '" class="calendar-title">' . $title . '</a>' . $n . "<br class=\"clear\"/></caption>\n<tr>\n"; foreach ($day_names as $d) { $calendar .= '<th abbr="' . htmlentities($d) . '">' . htmlentities(substr($d, 0, 3)) . ' </th>'; } $calendar .= "</tr>\n<tr>"; // Initial "empty" days if ($weekday > 0) { for ($i = 0; $i < $weekday; $i++) { $calendar .= '<td class="calendar-empty"> </td>'; } } for ($d = 1, $days_in_month = gmdate('t', $first_of_month); $d <= $days_in_month; $d++, $weekday++) { if ($weekday == 7) { // Start a new week $weekday = 0; $calendar .= "</tr>\n<tr>"; } $class = 'calendar-day'; $curr = date('Y-m-d', mktime(0, 0, 0, $month, $d, $year)); if (isset($events[$curr])) { $class .= ' calendar-day-events'; $content = '<a href="/event/calendar/' . _mycal_format_date($year, $month, $d) . '">' . $d . '</a>'; } else { $content = $d; } if (null !== $day && $d == $day) { $class .= ' calendar-day-selected'; } $calendar .= '<td class="' . $class . '">' . $content . '</td>'; } // Remaining "empty" days if ($weekday != 7) { for ($i = 0; $i < 7 - $weekday; $i++) { $calendar .= '<td class="calendar-empty"> </td>'; #initial 'empty' days } } return $calendar . "</tr>\n</table>\n"; }
function pleac_Printing_a_Date() { // 'date' and 'strftime' both print a date string based on: // * Format String, describing layout of date components // * Timestamp [*NIX Epoch Seconds], either given explicitly, or implictly // via a call to 'time' which retrieves current time value $ts = 1234567890; date('Y/m/d', $ts); date('Y/m/d', mktime($h, $m, $s, $mth, $d, $y, $is_dst)); date('Y/m/d'); // same as: date('Y/m/d', time()); // ------------ $ts = 1234567890; strftime('%Y/%m/%d', $ts); strftime('%Y/%m/%d', mktime($h, $m, $s, $mth, $d, $y, $is_dst)); strftime('%Y/%m/%d'); // same as: strftime('%Y/%m/%d', time()); // ---------------------------- // 'mktime' creates a local time timestamp $t = strftime('%a %b %e %H:%M:%S %z %Y', mktime(3, 45, 50, 1, 18, 73, TRUE)); echo "{$t}\n"; // 'gmmktime' creates a GMT time timestamp $t = strftime('%a %b %e %H:%M:%S %z %Y', gmmktime(3, 45, 50, 1, 18, 73)); echo "{$t}\n"; // ---------------------------- // 'strtotime' parses a textual date expression, and generates a timestamp $t = strftime('%A %D', strtotime('18 Jan 1973, 3:45:50')); echo "{$t}\n"; // This should generate output identical to previous example $t = strftime('%A %D', mktime(3, 45, 50, 1, 18, 73, TRUE)); echo "{$t}\n"; }
function get_related_dates($projectname, $basedate) { include "cdash/config.php"; require_once "cdash/pdo.php"; $dates = array(); $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}"); pdo_select_db("{$CDASH_DB_NAME}", $db); $dbQuery = pdo_query("SELECT nightlytime FROM project WHERE name='{$projectname}'"); if (pdo_num_rows($dbQuery) > 0) { $project = pdo_fetch_array($dbQuery); $nightlytime = $project['nightlytime']; //echo "query result nightlytime: " . $nightlytime . "<br/>"; } else { $nightlytime = "00:00:00"; //echo "default nightlytime: " . $nightlytime . "<br/>"; } if (!isset($basedate) || strlen($basedate) == 0) { $basedate = gmdate(FMT_DATE); } // Convert the nightly time into GMT $nightlytime = gmdate(FMT_TIME, strtotime($nightlytime)); $nightlyhour = time2hour($nightlytime); $nightlyminute = time2minute($nightlytime); $nightlysecond = time2second($nightlytime); $basemonth = date2month($basedate); $baseday = date2day($basedate); $baseyear = date2year($basedate); $dates['nightly+2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 2, $baseyear); $dates['nightly+1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 1, $baseyear); $dates['nightly-0'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday, $baseyear); $dates['nightly-1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 1, $baseyear); $dates['nightly-2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 2, $baseyear); // Snapshot of "now" // $currentgmtime = time(); $currentgmdate = gmdate(FMT_DATE, $currentgmtime); // Find the most recently past nightly time: // $todaymonth = date2month($currentgmdate); $todayday = date2day($currentgmdate); $todayyear = date2year($currentgmdate); $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear); while ($currentnightly > $currentgmtime) { $todayday = $todayday - 1; $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear); } $dates['now'] = $currentgmtime; $dates['most-recent-nightly'] = $currentnightly; $dates['today_utc'] = $currentgmdate; $dates['basedate'] = gmdate(FMT_DATE, $dates['nightly-0']); // CDash equivalent of DART1's "last rollup time" if ($dates['basedate'] === $dates['today_utc']) { // If it's today, it's now: $dates['last-rollup-time'] = $dates['now']; } else { // If it's not today, it's the nightly time on the basedate: $dates['last-rollup-time'] = $dates['nightly-0']; } return $dates; }
function global_header_mobile() { global $_G, $show_message; function dsu_signtz() { dheader('Location: plugin.php?id=dsu_paulsign:sign&mobile=yes'); } $var = $_G['cache']['plugin']['dsu_paulsign']; if (defined('IN_dsu_paulsign') || $show_message || defined('IN_dsu_paulsc') || !$_G['uid'] || !$var['ifopen'] || !$var['wap_sign']) { return ''; } $tdtime = gmmktime(0, 0, 0, dgmdate($_G['timestamp'], 'n', $var['tos']), dgmdate($_G['timestamp'], 'j', $var['tos']), dgmdate($_G['timestamp'], 'Y', $var['tos'])) - $var['tos'] * 3600; $allowmem = memory('check'); if ($var['ftopen'] && in_array($_G['groupid'], unserialize($var['tzgroupid'])) && !in_array($_G['uid'], explode(",", $var['ban'])) && in_array($_G['groupid'], unserialize($var['groups']))) { if ($allowmem && $var['mcacheopen']) { $signtime = memory('get', 'dsu_pualsign_' . $_G['uid']); } if (!$signtime) { $qiandaodb = DB::fetch_first("SELECT time FROM " . DB::table('dsu_paulsign') . " WHERE uid='{$_G['uid']}'"); $signtime = $qiandaodb['time']; $htime = dgmdate($_G['timestamp'], 'H', $var['tos']); if ($qiandaodb) { if ($allowmem && $var['mcacheopen']) { memory('set', 'dsu_pualsign_' . $_G['uid'], $qiandaodb['time'], 86400); } if ($qiandaodb['time'] < $tdtime) { if ($var['timeopen']) { if (!($htime < $var['stime']) && !($htime > $var['ftime'])) { return dsu_signtz(); } } else { return dsu_signtz(); } } } else { $ttps = DB::fetch_first("SELECT posts FROM " . DB::table('common_member_count') . " WHERE uid='{$_G['uid']}'"); if ($var['mintdpost'] <= $ttps['posts']) { if ($var['timeopen']) { if (!($htime < $var['stime']) && !($htime > $var['ftime'])) { return dsu_signtz(); } } else { return dsu_signtz(); } } } } else { if ($signtime < $tdtime) { if ($var['timeopen']) { if (!($htime < $var['stime']) && !($htime > $var['ftime'])) { return dsu_signtz(); } } else { return dsu_signtz(); } } } } return '<a href="plugin.php?id=dsu_paulsign:sign">' . lang('plugin/dsu_paulsign', 'name') . '</a>'; }
function parse_w3cdtf($date_str) { # regex to match wc3dtf $pat = "/(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})(:(\\d{2}))?(?:([-+])(\\d{2}):?(\\d{2})|(Z))?/"; if (preg_match($pat, $date_str, $match)) { list($year, $month, $day, $hours, $minutes, $seconds) = array($match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); # calc epoch for current date assuming GMT $epoch = gmmktime($hours, $minutes, $seconds, $month, $day, $year); $offset = 0; if ($match[10] == 'Z') { # zulu time, aka GMT } else { list($tz_mod, $tz_hour, $tz_min) = array($match[8], $match[9], $match[10]); # zero out the variables if (!$tz_hour) { $tz_hour = 0; } if (!$tz_min) { $tz_min = 0; } $offset_secs = ($tz_hour * 60 + $tz_min) * 60; # is timezone ahead of GMT? then subtract offset # if ($tz_mod == '+') { $offset_secs = $offset_secs * -1; } $offset = $offset_secs; } $epoch = $epoch + $offset; return $epoch; } else { return -1; } }
function chronos_time_ago($date) { $chunks = array(array(60 * 60 * 24 * 365, 'year', 'years'), array(60 * 60 * 24 * 30, 'month', 'months'), array(60 * 60 * 24 * 7, 'week', 'weeks'), array(60 * 60 * 24, 'day', 'days'), array(60 * 60, 'hour', 'hours'), array(60, 'minute', 'minutes'), array(1, 'second', 'seconds')); if (!is_numeric($date)) { $time_chunks = explode(':', str_replace(' ', ':', $date)); $date_chunks = explode('-', str_replace(' ', '-', $date)); $date = gmmktime((int) $time_chunks[1], (int) $time_chunks[2], (int) $time_chunks[3], (int) $date_chunks[1], (int) $date_chunks[2], (int) $date_chunks[0]); } $current_time = gmdate('Y-m-d H:i:s'); $newer_date = strtotime($current_time); $since = $newer_date - $date; if (0 > $since) { return 'sometime'; } for ($i = 0, $j = count($chunks); $i < $j; $i++) { $seconds = $chunks[$i][0]; if (($count = floor($since / $seconds)) != 0) { break; } } $output = 1 == $count ? '1 <span class="text-ago">' . $chunks[$i][1] : $count . ' <span class="text-ago">' . $chunks[$i][2]; if (!(int) trim($output)) { $output = '0' . 'seconds'; } $output .= ' ago</span>'; return $output; }
public function definition() { $mform =& $this->_form; $mform->addElement('header', 'addactivity', get_string('addactivity', 'report_cpd')); $mform->addElement('hidden', 'cpdyearid', $this->_customdata['cpdyearid']); $mform->addElement('hidden', 'process', '1'); if ($this->_customdata['cpdid']) { // This updates a CPD Report $mform->addElement('hidden', 'id', $this->_customdata['cpdid']); } $mform->addElement('textarea', 'objective', get_string('objective', 'report_cpd'), array('rows' => '2', 'cols' => '40')); $mform->addElement('textarea', 'development_need', get_string('developmentneed', 'report_cpd'), array('rows' => '2', 'cols' => '40')); if ($this->_customdata['activity_types']) { $mform->addElement('select', 'activitytypeid', get_string('activitytype', 'report_cpd'), $this->_customdata['activity_types']); } $mform->addElement('textarea', 'activity', get_string('activityplanned', 'report_cpd'), array('rows' => '2', 'cols' => '40')); // Get CPD start and end years $startyear = date('Y') - 5; $endyear = date('Y') + 5; if ($this->_customdata['cpdyear']) { $startyear = date('Y', $this->_customdata['cpdyear']->startdate); $endyear = date('Y', $this->_customdata['cpdyear']->enddate); } for ($i = 1; $i <= 31; $i++) { $days[$i] = $i; } for ($i = 1; $i <= 12; $i++) { $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B"); } for ($i = $startyear; $i <= $endyear; $i++) { $years[$i] = $i; } $startdate[] = $mform->createElement('select', 'startdate[d]', '', $days); $startdate[] = $mform->createElement('select', 'startdate[m]', '', $months); $startdate[] = $mform->createElement('select', 'startdate[Y]', '', $years); $mform->addGroup($startdate, 'startdate', get_string('datestart', 'report_cpd'), array(' '), false); $duedate[] = $mform->createElement('select', 'duedate[d]', '', $days); $duedate[] = $mform->createElement('select', 'duedate[m]', '', $months); $duedate[] = $mform->createElement('select', 'duedate[Y]', '', $years); $mform->addGroup($duedate, 'duedate', get_string('dateend', 'report_cpd'), array(' '), false); if ($this->_customdata['statuses']) { $mform->addElement('select', 'statusid', get_string('status', 'report_cpd'), $this->_customdata['statuses']); } $hours = null; $minutes = null; for ($i = 1; $i <= 20; $i++) { $hours[$i] = $i; } for ($i = 15; $i <= 45; $i += 15) { $minutes[$i] = $i; } $timetaken[] = $mform->createElement('select', 'timetaken[hours]', '', array('' => '--') + $hours); $timetaken[] = $mform->createElement('select', 'timetaken[minutes]', '', array('' => '--') + $minutes); $mform->addGroup($timetaken, 'timetaken', get_string('timetaken', 'report_cpd'), ':', false); $buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('update')); $buttonarray[] = $mform->createElement('reset', '', get_string('clear', 'report_cpd')); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); //$mform->addRule('objective', 'Please enter an objective.', 'required', null, 'client'); }
/** * \brief Ins�re le compte en base * \param user Utilisateur qui effectue l'insertion * \return int <0 si ko, Id ligne ajout�e si ok */ function create($user) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingaccount"; $sql.= " (date_creation, fk_user_author, numero,intitule)"; $sql.= " VALUES (".$this->db->idate(gmmktime()).",".$user->id.",'".$this->numero."','".$this->intitule."')"; $resql = $this->db->query($sql); if ($resql) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accountingaccount"); if ($id > 0) { $this->id = $id; $result = $this->id; } else { $result = -2; $this->error="AccountancyAccount::Create Erreur $result"; dol_syslog($this->error, LOG_ERR); } } else { $result = -1; $this->error="AccountancyAccount::Create Erreur $result"; dol_syslog($this->error, LOG_ERR); } return $result; }
static function getScoreContent($persons) { $user_ids = array_keys($persons); // News $query = "SELECT nr.range_id as user_id, COUNT(*) AS newscount FROM news_range AS nr INNER JOIN news AS n ON (nr.news_id = n.news_id) WHERE nr.range_id IN (?) AND (? - n.date) <= n.expire GROUP BY nr.range_id ORDER BY NULL"; $statement = DBManager::get()->prepare($query); $statement->execute(array($user_ids, gmmktime())); while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { $persons[$row['user_id']]['newscount'] = $row['newscount']; } // Events $query = "SELECT range_id as user_id, COUNT(*) AS eventcount FROM calendar_event INNER JOIN event_data ON (calendar_event.event_id = event_data.event_id AND class = 'PUBLIC') WHERE range_id IN (?) AND ? <= end GROUP BY range_id ORDER BY NULL"; $statement = DBManager::get()->prepare($query); $statement->execute(array($user_ids, gmmktime())); while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { $persons[$row['user_id']]['eventcount'] = $row['eventcount']; } // Literature $query = "SELECT range_id as user_id, COUNT(*) AS litcount FROM lit_list INNER JOIN lit_list_content USING (list_id) WHERE range_id IN (?) AND visibility = 1 GROUP BY range_id ORDER BY NULL"; $statement = DBManager::get()->prepare($query); $statement->execute(array($user_ids)); while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { $persons[$row['user_id']]['litcount'] = $row['litcount']; } // Votes if (get_config('VOTE_ENABLE')){ $query = "SELECT questionnaire_assignments.range_id as user_id, COUNT(*) AS votecount FROM questionnaire_assignments WHERE questionnaire_assignments.range_id IN (?) AND questionnaire_assignments.range_type = 'user' GROUP BY questionnaire_assignments.range_id ORDER BY NULL"; $statement = DBManager::get()->prepare($query); $statement->execute(array($user_ids)); while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { $persons[$row['user_id']]['votecount'] = $row['votecount']; } } return $persons; }
function realistic_time_ago() { global $post; $date = get_post_time('G', true, $post); // Array of time period chunks $chunks = array(array(60 * 60 * 24 * 365, __('year', 'realistic'), __('years', 'realistic')), array(60 * 60 * 24 * 30, __('month', 'realistic'), __('months', 'realistic')), array(60 * 60 * 24 * 7, __('week', 'realistic'), __('weeks', 'realistic')), array(60 * 60 * 24, __('day', 'realistic'), __('days', 'realistic')), array(60 * 60, __('hour', 'realistic'), __('hours', 'realistic')), array(60, __('minute', 'realistic'), __('minutes', 'realistic')), array(1, __('second', 'realistic'), __('seconds', 'realistic'))); if (!is_numeric($date)) { $time_chunks = explode(':', str_replace(' ', ':', $date)); $date_chunks = explode('-', str_replace(' ', '-', $date)); $date = gmmktime((int) $time_chunks[1], (int) $time_chunks[2], (int) $time_chunks[3], (int) $date_chunks[1], (int) $date_chunks[2], (int) $date_chunks[0]); } $current_time = current_time('mysql', $gmt = 0); $newer_date = strtotime($current_time); // Difference in seconds $since = $newer_date - $date; // Something went wrong with date calculation and we ended up with a negative date. if (0 > $since) { return __('sometime', 'realistic'); } //Step one: the first chunk for ($i = 0, $j = count($chunks); $i < $j; $i++) { $seconds = $chunks[$i][0]; // Finding the biggest chunk (if the chunk fits, break) if (($count = floor($since / $seconds)) != 0) { break; } } // Set output var $output = 1 == $count ? '1 ' . $chunks[$i][1] : $count . ' ' . $chunks[$i][2]; if (!(int) trim($output)) { $output = '0 ' . __('seconds', 'realistic'); } $output .= __(' ago', 'realistic'); return $output; }
function __construct($options = null) { if ($options == null) { if (isset($_POST['options'])) { $this->data = stripslashes_deep($_POST['options']); } } else { $this->data = $options; } if (isset($_REQUEST['act'])) { $this->action = $_REQUEST['act']; } if (isset($_REQUEST['btn'])) { $this->button_data = $_REQUEST['btn']; } // Fields analysis if (isset($_REQUEST['fields'])) { $fields = $_REQUEST['fields']; if (is_array($fields)) { foreach ($fields as $name => $type) { if ($type == 'datetime') { // Ex. The user insert 01/07/2012 14:30 and it set the time zone to +2. We cannot use the // mktime, since it uses the time zone of the machine. We create the time as if we are on // GMT 0 and then we subtract the GMT offset (the example date and time on GMT+2 happens // "before"). $time = gmmktime($_REQUEST[$name . '_hour'], 0, 0, $_REQUEST[$name . '_month'], $_REQUEST[$name . '_day'], $_REQUEST[$name . '_year']); $time -= get_option('gmt_offset') * 3600; $this->data[$name] = $time; } } } } }
/** * Convert a unix timestamp to a more presentalbe display * * @param $string * The unix timestamp to convert * @param $os * The offest, or timezone * @return the presentable time format */ function get_local_date($string, $os) { preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches); $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); $string_localtime = gmdate('M dS D, g:ia', $string_time + $os * 3600); return $string_localtime; }
public static function ConvertADDate($d) { if (preg_match('#(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})\\.(\\d)Z#', $d, $dt)) { return gmmktime($dt[4], $dt[5], $dt[6], $dt[2], $dt[3], $dt[1]); } return false; }
/** * (Web service method) Notify WordPress that the bot is online. * @param mixed[] $args an empty array * @return mixed[] status; error_message */ private function web_checkin($args) { $state = State::get_instance(); $state->last_checkin_utc = gmmktime(); $state->save(); return array('status' => 'ok', 'error_message' => ''); }