/** * Renders this page in content mode. * * @return string The page content. * @throws Wicked_Exception */ public function content() { global $wicked; $days = (int) Horde_Util::getGet('days', 3); $summaries = $wicked->getRecentChanges($days); if (count($summaries) < 10) { $summaries = $wicked->mostRecent(10); } $bydate = array(); $changes = array(); foreach ($summaries as $page) { $page = new Wicked_Page_StandardPage($page); $createDate = $page->versionCreated(); $tm = localtime($createDate, true); $createDate = mktime(0, 0, 0, $tm['tm_mon'], $tm['tm_mday'], $tm['tm_year'], $tm['tm_isdst']); $version_url = $page->pageUrl()->add('version', $page->version()); $diff_url = Horde::url('diff.php')->add(array('page' => $page->pageName(), 'v1' => '?', 'v2' => $page->version())); $diff_alt = sprintf(_("Show changes for %s"), $page->version()); $diff_img = Horde::img('diff.png', $diff_alt); $pageInfo = array('author' => $page->author(), 'name' => $page->pageName(), 'url' => $page->pageUrl(), 'version' => $page->version(), 'version_url' => $version_url, 'version_alt' => sprintf(_("Show version %s"), $page->version()), 'diff_url' => $diff_url, 'diff_alt' => $diff_alt, 'diff_img' => $diff_img, 'created' => $page->formatVersionCreated(), 'change_log' => $page->changeLog()); $bydate[$createDate][$page->versionCreated()][$page->version()] = $pageInfo; } krsort($bydate); foreach ($bydate as $bysecond) { $day = array(); krsort($bysecond); foreach ($bysecond as $pageList) { krsort($pageList); $day = array_merge($day, array_values($pageList)); } $changes[] = array('date' => $day[0]['created'], 'pages' => $day); } return $changes; }
/** * Handles an error * * @param $type string The type of the error * @param $string string The message of the error * @return bool */ public function handleError($type, $string) { $msg = ""; $caller = next(debug_backtrace()); if (isset($caller["file"])) { $file = $caller["file"]; } else { $file = ""; } if (isset($caller["line"])) { $line = $caller["line"]; } else { $line = 0; } date_default_timezone_set("Europe/Madrid"); $localTime = time(); $time = localtime($localTime, true); $errorExploded = explode("|", $string); $type = $errorExploded[0]; $type = trim($type); $type = strtolower($type); if (count($errorExploded) >= 2) { $msg = trim($errorExploded[1]); } else { $type = "error"; $msg = trim($string); } if ($msg == "") { $msg = $string; } return $this->_logError($type, $line, $msg, $file); }
function setTimezoneByOffset($offset) { date_default_timezone_set('UTC'); $testTimestamp = time(); $testLocaltime = localtime($testTimestamp, true); $testHour = $testLocaltime['tm_hour']; $abbrarray = timezone_abbreviations_list(); foreach ($abbrarray as $abbr) { foreach ($abbr as $city) { $val = false; if ($city['timezone_id'] != 'Factory' && '' . @$city['timezone_id'] > '') { if (isset($city['timezone_id'])) { $val = date_default_timezone_set($city['timezone_id']); if ($val) { $testLocaltime = localtime($testTimestamp, true); $hour = $testLocaltime['tm_hour']; $testOffset = $hour - $testHour; if ($testOffset == $offset || $testOffset == $offset + 24) { return true; } } } } } } date_default_timezone_set('UTC'); return false; }
function show() { $this->html_header(); $tasks = $this->db->getAll('SELECT permalink, postid, UNIX_TIMESTAMP(created_at) AS created_at, status FROM reblogs WHERE sessionkey = ? ORDER BY created_at DESC LIMIT 10', array($this->sessionkey)); $link = $this->permalink; if (count($tasks) > 0) { foreach ($tasks as $k => $task) { $link = $task['permalink']; $classname = ($k + 1) % 2 ? 'odd' : 'even'; print "<div class={$classname}>"; print "<a href=\"{$link}\">post" . $task["postid"] . "</a>\n"; print $task["status"] . "\n"; $t = localtime($task["created_at"] + 9 * 3600, true); printf("%d.%d.%d %02d:%02d", $t['tm_year'] + 1900, $t['tm_mon'], $t['tm_mday'], $t['tm_hour'], $t['tm_min']); print "</div>"; } } #$anchor = @$_REQUEST['anchor']; #header( #print ( # sprintf( "Location: /dashboard/%s?reblog=1&page=%s&anchor=%s&.rand=" . rand() . "#%s", # $this->sessionkey, # $this->page, # $anchor, # $anchor # ) #); $this->html_footer(); }
function quotaExpired($quotaString) { if (!preg_match("/,/", $quotaString)) { return 0; // No timestamp == not expired. } else { list($quotaPart, $timestampPart) = explode(",", $quotaString, 2); $timestampPart = rtrim($timestampPart); $tsLength = strlen($timestampPart); if (strlen($tsLength) == 0) { return 0; } else { if (strlen($timestampPart) != 12) { return 1; // The safe thing to do, return expired on errors. } } // Convert the timestamp into a nice array. $timestampArray = array((int) substr($timestampPart, 0, 4), (int) substr($timestampPart, 4, 2), (int) substr($timestampPart, 6, 2), (int) substr($timestampPart, 8, 2), (int) substr($timestampPart, 10, 2)); // Convert the localtime into a similar array. $currentTime = localtime(); $currentTimeArray = array((int) $currentTime[5] + 1900, (int) $currentTime[4] + 1, (int) $currentTime[3], (int) $currentTime[2], (int) $currentTime[1]); // Check each of the five values (year, month, day, hour, minute) in the timestamp for ($counter = 0; $counter <= 4; $counter++) { if ($timestampArray[$counter] < $currentTimeArray[$counter]) { return 1; } if ($timestampArray[$counter] > $currentTimeArray[$counter]) { return 0; } } return 1; } }
function send_email($user, $list, $filename, $to) { $name = basename($filename); $file_type = "application/xml"; // File Type $email_from = "*****@*****.**"; // Who the email is from $a = localtime(); $a[5] += 1900; $email_subject = "Updated " . $list . " list " . $a[5] . "-" . $a[4] . "-" . $a[3] . " " . $a[2] . ":" . $a[1] . ":" . $a[0]; // The Subject of the email $email_txt = "This is " . $user . "'s " . $list . " list"; // Message that the email has in it $email_to = $to; $headers = "From: " . $email_from; $file = fopen($filename, 'rb'); $data = fread($file, filesize($filename)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message = ""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_txt . "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$file_type};\n" . " name=\"{$name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; echo $email_to; echo $email_subject; echo $email_message; echo $headers; $ok = @mail($email_to, $email_subject, $email_message, $headers); return $ok; }
/** * Obtain tide information using the shortcode [us_tides tide_url='tide feed xml url'] * The format of the feed is expected to be as in the following output from bw_trace */ function us_time_of_day_secs() { extract(localtime(time(), true)); $secs = ($tm_hour * 60 + $tm_min) * 60 + $tm_sec; bw_trace($secs, __FUNCTION__, __LINE__, __FILE__, 'secs'); return $secs; }
function reportingDate(&$reportingmonth, &$reportdate) { date_default_timezone_set('America/Detroit'); $now = localtime(); //for ($i=0; $i<6; $i++) // print "now[" . $i . "]=" . $now[$i] . "\n"; // Reporting Month // $now[4] = current month [0..11] $rm = $now[4]; if ($now[3] > 25) { $rm = $rm + 1; } if ($rm > 11) { $rm = 0; } // Date report submitted $rn = $now; $rn[4] = $rm; //print "<p>mktime(" . 12 . "," . 0 . "," . 0 . // "," . $rm . "," . ($now[3]) . "," . ($now[5]+1900) . ")</p>\n"; $timestamp = mktime(12, 0, 0, $rm, $now[3], $now[5] + 1900); //print "<p>Timestamp:" . $timestamp . "</p>\n"; //print "<P>D=" . strftime("%Y",$timestamp) . "-" . strftime("%b",$timestamp) . "-" . strftime("%d",$timestamp) . "</p>\n"; $reportingmonth = strtoupper(strftime("%b", $timestamp)); $reportdate = strtoupper(strftime("%b %d", mktime())); $period = ($now[5] - 101) * 12 + $now[3] - 1; return $period; }
function subtract($time1, $time2) { $years = $time2[0] - $time1[0]; $months = $time2[1] - $time1[1]; $days = $time2[2] - $time1[2]; $hours = $time2[3] - $time1[3]; $minutes = $time2[4] - $time1[4]; $seconds = $time2[5] - $time1[5]; if ($seconds < 0) { $seconds += 60; $minutes -= 1; } if ($minutes < 0) { $minutes += 60; $hours -= 1; } if ($hours < 0) { $hours += 24; $days -= 1; } if ($days < 0) { $months -= 1; } if ($months < 0) { $months += 12; $years -= 1; } if ($days < 0) { $date = localtime(mktime(12, 0, 0, $time2[1], 31, $time2[0])); $days_in_month = 31 - $date[3] ? 31 - $date[3] : 31; $days += $days_in_month; } return array($years, $months, $days, $hours, $minutes, $seconds); }
function GetUptimeStatistics($pointID, $channelID, $fromDate, $toDate) { $getUptimeStatistics = true; $fromParts = explode('-', $fromDate); $toParts = explode('-', $toDate); $this->p_fromDate = $fromParts[2] . '-' . $fromParts[0] . '-' . $fromParts[1]; $this->p_toDate = $toParts[2] . '-' . $toParts[0] . '-' . $toParts[1]; $sql = "select\n iss.PointObjectID,\n iss.ChannelID,\n count(*) ActualIntervals,\n (to_days('" . $this->p_toDate . "') - to_days('" . $this->p_fromDate . "'))*1440/p.ReadInterval +\n if('" . $this->p_toDate . "' = curdate(), floor(time_to_sec(curtime())/(60 * p.ReadInterval)), 1440/p.ReadInterval) ExpectedIntervals,\n date_sub(pcs.LastUnfilledIntervalDate,\n INTERVAL if((pcs.LastUnfilledIntervalDate >= '2006-04-02 06:00:00' and pcs.LastUnfilledIntervalDate <= '2006-10-29 06:00:00') or\n (pcs.LastUnfilledIntervalDate >= '2007-03-11 06:00:00' and pcs.LastUnfilledIntervalDate <= '2007-11-04 06:00:00') or\n (pcs.LastUnfilledIntervalDate >= '2008-03-09 06:00:00' and pcs.LastUnfilledIntervalDate <= '2008-11-02 06:00:00') or\n (pcs.LastUnfilledIntervalDate >= '2009-03-08 06:00:00' and pcs.LastUnfilledIntervalDate <= '2009-11-01 06:00:00') or\n (pcs.LastUnfilledIntervalDate >= '2010-03-07 06:00:00' and pcs.LastUnfilledIntervalDate <= '2010-11-07 06:00:00'), 4, 5) HOUR) LastIntervalDate\n from\n t_intervalsettypes ist,\n t_intervalsets iss,\n t_intervals i,\n t_points p,\n t_pointchannelstatistics pcs\n where\n ist.IntervalSetTypeName = 'IntervalSet' and\n iss.IntervalSetTypeID = ist.IntervalSetTypeID and\n iss.PointObjectID = " . $pointID . " and\n iss.ChannelID = " . $channelID . " and\n iss.IntervalSetBaseDate between '" . $this->p_fromDate . "' and '" . $this->p_toDate . "' and\n i.IntervalSetID = iss.IntervalSetID and\n (i.IsFilled = 0 or\n i.CreatedDate > i.UpdatedDate) and\n pcs.ObjectID = iss.PointObjectID and\n pcs.ChannelID = iss.ChannelID and\n p.ObjectID = pcs.ObjectID\n group by\n iss.PointObjectID,\n iss.ChannelID"; $result = mysql_query($sql, $this->sqlConnection()); //$this->preDebugger($sql); if ($row = mysql_fetch_array($result)) { $this->p_actualIntervals = $row["ActualIntervals"]; $this->p_expectedIntervals = round($row['ExpectedIntervals'], 0); $this->p_percentageUptime = round($this->p_actualIntervals / $this->p_expectedIntervals * 100.0, 2); $this->p_percentageFilled = round(100.0 - $this->p_percentageUptime, 2); $this->p_lastIntervalDate = $row["LastIntervalDate"]; } else { $localTime = localtime(time(), true); $localSecs = ($localTime['tm_hour'] * 60 + $localTime['tm_min']) * 60 + $localTime['tm_sec']; $this->p_actualIntervals = 0; $this->p_expectedIntervals = (strtotime($toDate) - strtotime($fromDate)) / 300 + ($toDate == date("m-d-Y") ? floor($localSecs / 300) : 288); $this->p_percentageUptime = 0; $this->p_percentageFilled = "--"; $this->p_lastIntervalDate = "??"; } return $getUptimeStatistics; }
function WF_CleanUpHistory() { if (CModule::IncludeModule("workflow")) { global $DB; $HISTORY_DAYS = COption::GetOptionInt("workflow", "HISTORY_DAYS", -1); if ($HISTORY_DAYS >= 0) { $arDate = localtime(time()); $date = mktime(0, 0, 0, $arDate[4] + 1, $arDate[3] - $HISTORY_DAYS, 1900 + $arDate[5]); CTimeZone::Disable(); $strSql = "\n\t\t\t\t\tSELECT ID, WF_PARENT_ELEMENT_ID\n\t\t\t\t\tFROM b_iblock_element\n\t\t\t\t\tWHERE TIMESTAMP_X <= " . $DB->CharToDateFunction(ConvertTimeStamp($date, "FULL")) . "\n\t\t\t\t\tAND WF_PARENT_ELEMENT_ID is not null\n\t\t\t\t\tORDER BY ID DESC\n\t\t\t\t"; $rsElements = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__); CTimeZone::Enable(); //This Fetch will keep at least one history copy //in order to prevent files being deleted //before they copied into working copy if ($rsElements->Fetch()) { while ($arElement = $rsElements->Fetch()) { $LAST_ID = CIBlockElement::WF_GetLast($arElement["WF_PARENT_ELEMENT_ID"]); if ($LAST_ID != $arElement["ID"]) { CIBlockElement::Delete($arElement["ID"]); } } } } } }
function SendCommentsTwits($debug) { $default = 0; $Yesterday = mktime(0, 0, 0, date("m"), date("d") - (1 - $default), date("Y")); $LocalTime = localtime(); if ($LocalTime[2] < 6) { $Today = $Yesterday; $Yesterday = mktime(0, 0, 0, date("m"), date("d") - (2 - $default), date("Y")); } else { $Today = mktime(0, 0, 0, date("m"), date("d") - $default, date("Y")); } $ThisDate = date("Y-m-d", $Yesterday); $qq = "select *,New_opinion.id as Oid, New_company.name as CompanyName from New_opinion,New_company,New_expert where\n\t\tNew_opinion.company_id = New_company.id and \n\t\tNew_opinion.expert_id=New_expert.id and New_opinion.signal_id=6 and New_opinion.Date>=\"{$ThisDate}\""; // New_opinion.signal_id==3 is comment if ($debug) { echo "Query is <br>{$qq}<br>"; } $result1 = mysql_query($qq); echo mysql_error(); $NumAlerts = mysql_num_rows($result1); echo mysql_error(); echo "Number of alerts is {$NumAlerts}<br>"; if ($debug) { echo '<br>Debug'; } for ($an = 0; $an < $NumAlerts; $an++) { $row1 = mysql_fetch_assoc($result1); // foreach ($row1 as $key => $ra) // echo "<br>$key is $ra"; //$cl = slink('http://www.stockchase.com/Company?ID='. $row1['company'],'','','','',$row1['company']); $cl = '#stock #invest #' . $row1['symbol'] . ' http://www.stockchase.com'; $companyline = 'http://www.stockchase.com/company/view/' . $row1['company_id'] . '/' . $row1['Oid']; $companyline = getBitUrl($companyline); $companyname = $row1['CompanyName']; if (strlen($companyname > 10)) { $companyname = substr($companyname, 0, 7); $companyname .= '...'; } $cl = $companyline . ' #trading #finance'; // $cl = 'http://www.stockchase.com/Opinion.php'; // $cl = 'http://tinyurl.com/5dqmwd'; $twitterStatus = strip_tags($row1['comment']); $twitterStatus = str_replace(' ', ' ', $twitterStatus); if (strlen($twitterStatus . $cl) > 140) { $twitterStatus1 = substr($twitterStatus, 0, 137 - strlen($cl)); $twitterStatus = $twitterStatus1 . "..."; } $twitterStatus .= $cl; echo '<br>'; echo $twitterStatus; if ($debug) { echo "<br>{$an} Would send to twitter <b>{$twitterStatus}</b>"; } else { // $this->tweet->call('post','statuses/update',array('status' => $twitterStatus)); echo shell_exec('/home/stockchase/EditorFunctions/python/mytweet.py "' . $twitterStatus . '"'); flush(); sleep(60 * 5); } } }
function update_timesheet($ts_finish) { global $ts_no, $ts_start, $ts_description, $client_messages, $dow, $sow, $session; $session->Dbg("TimeSheet", "Updating timesheet for {$ts_finish}"); $ts_finish = intval($ts_finish); if ($ts_no > 0 && $ts_finish > 0) { $session->Dbg("TimeSheet", "Write timesheet from {$ts_start} to {$ts_finish} for {$ts_no} '{$ts_description}'"); $qry = new PgQuery("SELECT request_id FROM request WHERE request_id = ?", $ts_no); if (!$qry->Exec("TimeSheet") || $qry->rows == 0) { $client_messages[] = "WR # {$ts_no} was not found."; $session->Dbg("TimeSheet", "WR# {$ts_no} '{$ts_description}' was not found."); } else { $lt = localtime($sow, true); $session->Dbg("TimeSheet", "Time includes DST? " . $lt['tm_isdst']); $from = date('Y-M-d, H:i', $sow + $dow * 86400 + ($ts_start - 60 * $lt['tm_isdst']) * 60); $duration = sprintf("%d minutes", $ts_finish - $ts_start); $quantity = ($ts_finish - $ts_start) / 60; $description = ereg_replace("@\\|@.*\$", "", $ts_description); $sql = "INSERT INTO request_timesheet ( request_id, work_on, work_duration, work_quantity, work_by_id, work_description, work_units, entry_details ) "; $sql .= "VALUES( ?, ?::timestamp without time zone, ?::interval, ?, {$session->user_no}, ?, 'hours', "; $sql .= sprintf("'TS-%d-%d');", $session->user_no, $sow); $qry = new PgQuery($sql, $ts_no, $from, $duration, $quantity, $description); $qry->Exec("TimeSheet"); } } else { $session->Dbg("TimeSheet", "Not writing timesheet from {$ts_start} to {$ts_finish} for {$ts_no} '{$ts_description}'"); } $ts_no = 0; $ts_start = 0; $ts_description = ""; return; }
function pleac_Finding_Today_s_Date() { define(SEP, '-'); // ------------ $today = getdate(); $day = $today['mday']; $month = $today['mon']; $year = $today['year']; // Either do this to use interpolation: $sep = SEP; echo "Current date is: {$year}{$sep}{$month}{$sep}{$day}\n"; // or simply concatenate: echo 'Current date is: ' . $year . SEP . $month . SEP . $day . "\n"; // ------------ $today = localtime(time(), TRUE); $day = $today['tm_mday']; $month = $today['tm_mon'] + 1; $year = $today['tm_year'] + 1900; printf("Current date is: %4d%s%2d%s%2d\n", $year, SEP, $month, SEP, $day); // ------------ $format = 'Y' . SEP . 'n' . SEP . 'd'; $today = date($format); echo "Current date is: {$today}\n"; // ------------ $sep = SEP; $today = strftime("%Y{$sep}%m{$sep}%d"); echo "Current date is: {$today}\n"; }
function registraException($e) { $string = "ERRO: " . $e->getMessage() . ";CODIGO: " . $e->getCode() . ";ARQUIVO: " . $e->getFile() . ";LINHA: " . $e->getLine() . ";DATA: " . getdate() . " " . localtime() . "|"; $pointer = fopen(BASEPATH . '/application/txt/exceptions.txt', 'w'); fwrite($pointer, $string); fclose($pointer); }
function __construct() { $this->day = strtolower(date('l')); // monday, tuedsay .... $ltime = localtime(); $this->time = $ltime[2] * 60 * 60 + $ltime[1] * 60 + $ltime[0]; // seconds past in day }
public function __construct(\Arii\CoreBundle\Service\AriiSession $session, \FOS\UserBundle\Doctrine\UserManager $userManager, \Doctrine\ORM\EntityManager $entityManager) { $this->session = $session; $this->userManager = $userManager; $this->entityManager = $entityManager; $localtime = localtime(time(), true); // $this->when = sprintf(); }
public static function parse($text) { $localtime = localtime(); $dst = $localtime[8]; //$dst = $this->time->date("I"); // Determine the event and raid times $regex = '~\\[(?<time>.*)\\].*\\((?<event>.*)\\).*~'; preg_match_all($regex, $text, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $event = trim($match['event']); $start = $end = trim($match['time']); if (!is_numeric($event)) { $data['zones'][] = array('', $dst ? strtotime('+1 hours', strtotime($start)) : strtotime($start), $dst ? strtotime('+1 hours', strtotime($end)) : strtotime($end), 0, $event); } //if (!is_numeric($event)) $data['zones'][] = array('', strtotime($start), strtotime($end), 0, $event); } // Determine the members attending the raid $regex = '~((\\[ANONYMOUS\\])|((\\[(?<lvl>[0-9]{1,3})\\h(?<title>\\w*\\s?\\w*)\\h\\((?<class>.*)\\)\\])))\\h(?<name>\\w*)\\h*((\\((?<race>.*)\\))*\\h*(<(?<guild>.*)>)*)*~'; preg_match_all($regex, $text, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $name = trim($match['name']); $lvl = trim($match['lvl']); $title = isset($match['title']) ? trim($match['title']) : ''; $class = isset($match['class']) ? trim($match['class']) : ''; $race = isset($match['race']) ? trim($match['race']) : ''; $data['members'][] = array($name, $class, $race, $lvl); $data['times'][] = array($name, time() - 2 * 3600, 'join'); $data['times'][] = array($name, time(), 'leave'); } // Add the bench to the raid $regex = '~\\(\\w*\\).*:\\R(\\[.*\\]\\h(?<mbrlist>.*))*~'; preg_match_all($regex, $text, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $mbrlist = trim($match['mbrlist']); $regex = '~(?<name>\\w+)(,\\h)?~'; preg_match_all($regex, $mbrlist, $mbrmatches, PREG_SET_ORDER); foreach ($mbrmatches as $mbrmatch) { $name = trim($mbrmatch['name']); $data['members'][] = array($name); $data['times'][] = array($name, time() - 2 * 3600, 'join'); $data['times'][] = array($name, time(), 'leave'); } } // Determine the loot dropped and purchased $regex = '~\\[.*\\].*\'LOOT:\\h(?<item>.*)\\h(?<name>\\w*)\\h(?<cost>[0-9]+)\'~'; preg_match_all($regex, $text, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $item = trim($match['item']); $name = trim($match['name']); $cost = trim($match['cost']); if ($name == 'ROT') { $name = ''; } $data['items'][] = array($item, $name, $cost, '', ''); } return $data; }
private function _is_leap() { $time = strtotime($this->year . "-02-29"); $time_array = localtime($time); if ($time_array[4] == 1) { return true; } return false; }
function GetDOW($default = 0) { global $Today; global $Yesterday; global $ThisDateAsInt; global $ThisDate; global $Back7Days; $Back7Days = mktime(0, 0, 0, date("m"), date("d") - (7 - $default), date("Y")); $Yesterday = mktime(0, 0, 0, date("m"), date("d") - (1 - $default), date("Y")); $LocalTime = localtime(); if ($LocalTime[2] < 6) { $Today = $Yesterday; $Yesterday = mktime(0, 0, 0, date("m"), date("d") - (2 - $default), date("Y")); } else { $Today = mktime(0, 0, 0, date("m"), date("d") - $default, date("Y")); } //else $Today = time(); //echo "Today is $Today, Yesterday is $Yesterday"; $ThisDate = date("Y-m-d", $Today); $ThisDateAsInt = time(); //date("Y-m-d",$Today); $LocalTime = localtime(); $DayOfWeek = date("N"); $DayOfWeek = $DayOfWeek + $default; if ($LocalTime[2] < 6) { $DayOfWeek = $DayOfWeek - 1; echo 'Time before 6am, setting day back one<br>'; } $DayOfWeek = $DayOfWeek % 7; switch ($DayOfWeek) { case 0: $DayOfWeek = 'Sunday'; break; case 1: $DayOfWeek = 'Monday'; break; case 2: $DayOfWeek = 'Tuesday'; break; case 3: $DayOfWeek = 'Wednesday'; break; case 4: $DayOfWeek = 'Thursday'; break; case 5: $DayOfWeek = 'Friday'; break; case 6: $DayOfWeek = 'Saturday'; break; case 7: $DayOfWeek = 'Sunday'; break; } return $DayOfWeek; }
public function ajaxGetNodeInfo($params, &$ajaxObj) { $node_id = t3lib_div::_GP('node'); $node_repository = tx_caretaker_NodeRepository::getInstance(); if ($node_id && ($node = $node_repository->id2node($node_id, true))) { $local_time = localtime(time(), true); $local_hour = $local_time['tm_hour']; $pathnode = $node; $pathparts = array(); while ($pathnode) { $pathparts[] = $pathnode->getTitle(); $pathnode = $pathnode->getParent(); } $pathinfo = implode(' -> ', array_reverse($pathparts)); switch (get_class($node)) { // test Node case "tx_caretaker_TestNode": $interval_info = ''; $interval = $node->getInterval(); if ($interval < 60) { $interval_info .= $interval . ' Seconds'; } else { if ($interval < 60 * 60) { $interval_info .= $interval / 60 . ' Minutes'; } else { if ($interval < 60 * 60 * 24) { $interval_info .= $interval / (60 * 60) . ' Hours'; } else { $interval_info .= $interval / 86400 . ' Days'; } } } if ($node->getStartHour() || $node->getStopHour() > 0) { $interval_info .= ' ['; if ($node->getStartHour()) { $interval_info .= ' after:' . $node->getStartHour(); } if ($node->getStopHour()) { $interval_info .= ' before:' . $node->getStopHour(); } $interval_info .= ' ]'; } $result = $node->getTestResult(); $info = '<div class="tx_caretaker_node_info tx_caretaker_node_info_state_' . strtolower($result->getStateInfo()) . '">' . 'Title: ' . $node->getTitle() . '<br/>' . 'Path: ' . $pathinfo . '<br/>' . 'NodeID: ' . $node->getCaretakerNodeId() . '<br/>' . 'Type: ' . $node->getTypeDescription() . '<br/>' . 'Interval: ' . $interval_info . '<br/>' . 'Description: ' . $node->getDescription() . '<br/>' . 'Configuration: ' . $node->getConfigurationInfo() . '<br/>' . 'Hidden: ' . $node->getHiddenInfo() . '<br/>' . 'last Run: ' . strftime('%x %X', $result->getTimestamp()) . '<br/>' . 'State: ' . $result->getLocallizedStateInfo() . '<br/>' . 'Value: ' . $result->getValue() . '<br/>' . 'Message: ' . '<br/>' . nl2br($result->getLocallizedInfotext()) . '<br/>' . '</div>'; break; default: // aggregator Node $result = $node->getTestResult(); $info = '<div class="tx_caretaker_node_info tx_caretaker_node_info_state_' . strtolower($result->getStateInfo()) . '">' . 'Title: ' . $node->getTitle() . '<br/>' . 'Path: ' . $pathinfo . '<br/>' . 'NodeID: ' . $node->getCaretakerNodeId() . '<br/>' . 'Description: ' . $node->getDescription() . '<br/>' . 'Hidden: ' . $node->getHiddenInfo() . '<br/>' . 'last Run: ' . strftime('%x %X', $result->getTimestamp()) . '<br/>' . 'State: ' . $result->getLocallizedStateInfo() . '<br/>' . 'Message:' . '<br/>' . nl2br($result->getLocallizedInfotext()) . '<br/>' . '</div>'; break; } echo $info; } else { echo "please select a node"; } }
function pleac_Introduction() { // PHP's date / time suport is quite extensive, and appears grouped into three areas of // functionality: // // * UNIX / C Library [libc]-based routines, which include [among others]: // - localtime, gmtime // - strftime, strptime, mktime // - time, getdate, gettimeofday, // // * PHP 'native' functions, those date / time routines released in earlier versions, // and which otherwise provide 'convenience' functionality; these include: // - date // - strtotime // // * 'DateTime' class-based. This facility appears [according to the PHP documentation] // to be extremely new / experimental, so whilst usage examples will be provided, they // should not be taken to be 'official' examples, and obviously, subject to change. // My own impression is that this facility is currently only partially implemented, // so there is limited use for these functions. The functions included in this group // are some of the 'date_'-prefixed functions; they are, however, not used standalone, // but as methods in conjunction with an object. Typical usage: // // $today = new DateTime(); // actually calls: date_create($today, ...); // echo $today->format('U') . "\n"; // actually calls: date_format($today, ...); // // Also worth mentioning is the PEAR [PHP Extension and Repository] package, 'Calendar', // which offers a rich set of date / time manipulation facilities. However, since it is // not currently shipped with PHP, no examples appear // Helper functions for performing date arithmetic function dateOffset() { static $tbl = array('sec' => 1, 'min' => 60, 'hou' => 3600, 'day' => 86400, 'wee' => 604800); $delta = 0; foreach (func_get_args() as $arg) { $kv = explode('=', $arg); $delta += $kv[1] * $tbl[strtolower(substr($kv[0], 0, 3))]; } return $delta; } function dateInterval($intvltype, $timevalue) { static $tbl = array('sec' => 1, 'min' => 60, 'hou' => 3600, 'day' => 86400, 'wee' => 604800); return (int) round($timevalue / $tbl[strtolower(substr($intvltype, 0, 3))]); } // ---------------------------- // Extract indexed array from 'getdate' $today = getdate(); printf("Today is day %d of the current year\n", $today['yday']); // Extract indexed, and associative arrays, respectively, from 'localtime' $today = localtime(); printf("Today is day %d of the current year\n", $today[7]); $today = localtime(time(), TRUE); printf("Today is day %d of the current year\n", $today['tm_yday']); }
public static function Unix2SQL($unixtime, $is_date_only = false) { list($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($unixtime); $year += 1900; $mon += 1; if ($is_date_only) { return "{$year}-{$mon}-{$mday}"; } else { return "{$year}-{$mon}-{$mday} {$hour}:{$min}:{$sec}"; } }
function getImportExcelData($data, $fields) { global $total_records, $cCharset, $columnIndex; foreach ($data->getWorksheetIterator() as $worksheet) { $highestRow = $worksheet->getHighestRow(); for ($row = 2; $row <= $highestRow; ++$row) { for ($col = 0; $col < $columnIndex; ++$col) { $cell = $worksheet->getCellByColumnAndRow($col, $row); if (PHPExcel_Shared_Date::isDateTime($cell)) { $date_format = $cell->getParent()->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode(); $value = PHPExcel_Style_NumberFormat::ToFormattedString($cell->getValue(), $date_format); if (is_a($value, 'PHPExcel_RichText')) { $value = $value->getPlainText(); } if ($value) { $time = array(); if (strtotime($value)) { $value = strtotime($value); } else { $d_format = ""; for ($i = 0; $i < strlen($date_format); $i++) { $letter = substr(strtolower($date_format), $i, 1); if ($letter == "d" || $letter == "m" || $letter == "y") { if (strpos($d_format, $letter) === false) { $d_format .= $letter; } } } $value = strtotime(localdatetime2db($value, $d_format)); } // $value = PHPExcel_Shared_Date::ExcelToPHP($value); $time = localtime($value, true); $val = $time["tm_year"] + 1900 . "-" . ($time["tm_mon"] + 1) . "-" . $time["tm_mday"] . " " . $time["tm_hour"] . ":" . $time["tm_min"] . ":" . $time["tm_sec"]; } else { $val = NULL; } } else { $error_handler = set_error_handler("empty_error_handler"); $val = PHPExcel_Shared_String::ConvertEncoding($cell->getValue(), $cCharset, 'UTF-8'); if (is_a($val, 'PHPExcel_RichText')) { $val = $val->getPlainText(); } if ($error_handler) { set_error_handler($error_handler); } } $arr[$fields[$col]] = $val; } $ret = InsertRecord($arr, $row - 2); $total_records++; } break; } }
function CleanUpAgent() { global $DB; $cleanup_days = COption::GetOptionInt("main", "event_log_cleanup_days", 7); if ($cleanup_days > 0) { $arDate = localtime(time()); $date = mktime(0, 0, 0, $arDate[4] + 1, $arDate[3] - $cleanup_days, 1900 + $arDate[5]); $DB->Query("DELETE FROM b_event_log WHERE TIMESTAMP_X <= " . $DB->CharToDateFunction(ConvertTimeStamp($date, "FULL"))); } return "CEventLog::CleanUpAgent();"; }
public static function getYear() { return Session::get('schoolyear', function () { $time = localtime(); if ($time[4] >= 8) { return 1900 + $time[5]; } else { return 1900 + $time[5] - 1; } }); }
public function ribbonAction() { // Date du jour $date = localtime(time(), true); $date['Year'] = $date['tm_year'] + 1900; $date['Month'] = $date['tm_mon'] + 1; $date['Day'] = $date['tm_mday']; $response = new Response(); $response->headers->set('Content-Type', 'application/json'); return $this->render('AriiGalleryBundle:Default:ribbon.json.twig', array('Date' => $date), $response); }
/** * Populates the given DatabaseObject with dummy data * * @param DatabaseObject $obj * @return void */ protected function populate(DatabaseObject &$obj) { $meta = $obj->meta(); $key = $meta->getKey(); $fields = $meta->getColumnMap(); foreach ($fields as $property => $field) { if ($field == $key && isset($obj->{$property})) { continue; } $def = $meta->getColumnDefinition($field); $type = strtolower(Params::generic($def, 'native_type')); switch ($type) { case 'int': case 'integer': case 'float': case 'currency': case 'decimal': case 'double': case 'real': case 'tinyint': case 'short': case 'long': $obj->{$property} = mt_rand(0, 100); break; case 'date': case 'datetime': case 'timestamp': // Fuzz two weeks around now $window = 1209600; // 14 days * 24 hours * 60 minutes * 60 seconds $time = time() - $window / 2 + mt_rand(0, $window); if ($type == 'date') { $lt = localtime($time, true); $time = mktime(0, 0, 0, $lt['tm_mday'], $lt['tm_mon'] + 1, $lt['tm_year'] + 1900); $lt = null; } $obj->{$property} = $time; break; case 'time': // range is +- 838:59:59, but since this populate thing // isn't really all it could be anyhow, let's just do // positive values $obj->{$property} = mt_rand(1, 839 * 60 * 60 - 1); break; case 'var_string': $obj->{$property} = 'dummy string content ' . uniqid(); break; default: $obj->{$property} = uniqid(); break; } } }
/** * Get db prepared dateTime value * @param String textValue * @param String dateFormat * @return String */ function getDBDateValue($textValue, $dateFormat) { if (!$textValue) { return NULL; } $timeStamp = getTimeStamp($textValue, $dateFormat); if ($timeStamp === FALSE) { return NULL; } $time = localtime($timeStamp, true); return $time["tm_year"] + 1900 . "-" . ($time["tm_mon"] + 1) . "-" . $time["tm_mday"] . " " . $time["tm_hour"] . ":" . $time["tm_min"] . ":" . $time["tm_sec"]; }
function timezone_time($zone, $date = 0) { $tz = getenv("TZ"); putenv("TZ={$zone}"); if ($date == 0) { $ret = localtime(time(), TRUE); } else { $ret = localtime($date, TRUE); } putenv("TZ={$tz}"); return $ret; }