public function updateCMSFields(FieldList $fields) { $fields->removeByName('LastSignificantChange'); $fields->removeByName('ChangeDescription'); if ($this->owner->LastSignificantChange !== NULL) { $dateTime = new DateTime($this->owner->LastSignificantChange); //Put these fields on the top of the First Tab's form $fields->first()->Tabs()->first()->getChildren()->unshift(LabelField::create("infoLastSignificantChange", "<strong>Last Significant change was at: " . "{$dateTime->Format('d/m/Y H:i')}</strong>")); $fields->insertAfter(CheckboxField::create("isSignificantChange", "CLEAR Last Significant change: {$dateTime->Format('d/m/Y H:i')}")->setDescription('Check and save this Record again to clear the Last Significant change date.')->setValue(FALSE), 'infoLastSignificantChange'); $fields->insertAfter(TextField::create('ChangeDescription', 'Description of Changes')->setDescription('This is an automatically generated list of changes to important fields.'), 'isSignificantChange'); } }
public function LatestTweetsList($limit = '5') { $conf = SiteConfig::current_site_config(); if (empty($conf->TwitterName) || empty($conf->TwitterConsumerKey) || empty($conf->TwitterConsumerSecret) || empty($conf->TwitterAccessToken) || empty($conf->TwitterAccessTokenSecret)) { return new ArrayList(); } $cache = SS_Cache::factory('LatestTweets_cache'); if (!($results = unserialize($cache->load(__FUNCTION__)))) { $results = new ArrayList(); require_once dirname(__FILE__) . '/tmhOAuth/tmhOAuth.php'; require_once dirname(__FILE__) . '/tmhOAuth/tmhUtilities.php'; $tmhOAuth = new tmhOAuth(array('consumer_key' => $conf->TwitterConsumerKey, 'consumer_secret' => $conf->TwitterConsumerSecret, 'user_token' => $conf->TwitterAccessToken, 'user_secret' => $conf->TwitterAccessTokenSecret, 'curl_ssl_verifypeer' => false)); $code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => $conf->TwitterName, 'count' => $limit)); $tweets = $tmhOAuth->response['response']; $json = new JSONDataFormatter(); if (($arr = $json->convertStringToArray($tweets)) && is_array($arr) && isset($arr[0]['text'])) { foreach ($arr as $tweet) { try { $here = new DateTime(SS_Datetime::now()->getValue()); $there = new DateTime($tweet['created_at']); $there->setTimezone($here->getTimezone()); $date = $there->Format('Y-m-d H:i:s'); } catch (Exception $e) { $date = 0; } $results->push(new ArrayData(array('Text' => nl2br(tmhUtilities::entify_with_options($tweet, array('target' => '_blank'))), 'Date' => SS_Datetime::create_field('SS_Datetime', $date)))); } } $cache->save(serialize($results), __FUNCTION__); } return $results; }
public function setValue($value, $record = null) { if ($value === false || $value === null || is_string($value) && !strlen($value)) { // don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be // saved as NULL in database $this->value = null; return; } // Default to NZ date format - strtotime expects a US date if (preg_match('#^([0-9]+)/([0-9]+)/([0-9]+)$#', $value, $parts)) { $value = "{$parts['2']}/{$parts['1']}/{$parts['3']}"; } if (is_numeric($value)) { $this->value = date('Y-m-d H:i:s', $value); } elseif (is_string($value)) { // $this->value = date('Y-m-d H:i:s', strtotime($value)); try { $date = new DateTime($value); $this->value = $date->Format('Y-m-d H:i:s'); return; } catch (Exception $e) { $this->value = null; return; } } }
/** * Returns the date in the raw SQL-format specific to a given timezone passed from the Member class, e.g. “2006-01-18 16:32:04” */ public function Format($format) { if ($this->value) { $date = new DateTime($this->value); //if the current user has set a timezone that is not the default then use that $member = $this->getCurrentCachedUser(); if ($member && $member->exists() && $member->Timezone && $member->Timezone != date_default_timezone_get()) { $date->setTimezone(new DateTimeZone($member->Timezone)); } return $date->Format($format); } }
function converterGetData() { global $fh; $line = fgets($fh); if($line === false) { return false; } $la = preg_split("/(\s*\|\s*)/", $line); $date = substr($la[0],1); $d = new DateTime($date); $date = $d->Format('d.m.Y H:i:s'); $day = $d->Format('d'); $hour = $d->Format('H'); $res = array(); $res['src'] = $date."\t".$la[3]."\t".$la[1]."\t".($la[1])."\t".$la[2]."\t".($la[2])."\tA0\tB0\t0\t".$la[3]."\t0\n"; $res['gibs'] = explode("\t", $res['src']); return $res; }
/** * Return the date using a particular formatting string. * * @param string $format Format code string. e.g. "d M Y" (see http://php.net/date) * @param mixed $value Value to format * @return string The date in the requested format */ public static function Format($format, $value) { if ($value) { // Use current locale if different from configured i18n locale $i18nLocale = $currentLocale = i18n::get_locale(); if (class_exists("Translatable")) { $currentLocale = Translatable::get_current_locale(); } if (self::$locale) { $currentLocale = self::$locale; } if ($currentLocale != $i18nLocale) { i18n::set_locale($currentLocale); } // Set date $date = new DateTime($value); // Flag escaped chars (or there will be problems with formats like "F\D") $escapeId = '-' . time() . '-'; $format = str_replace('\\', $escapeId . '\\', $format); // Get formatted date $dateStr = $date->Format($format); // Translate all word-strings $dateStr = preg_replace_callback("/([a-z]*)([^a-z])/isU", function ($m) { if (empty($m[1])) { // Nothing to translate return $m[0]; } return _t('LocalDate.' . $m[1], $m[1]) . $m[2]; }, $dateStr . ' '); // Remove escape flags $dateStr = str_replace($escapeId, '', $dateStr); // Reset i18n locale if ($currentLocale != $i18nLocale) { i18n::set_locale($i18nLocale); } // Return translated date string return substr($dateStr, 0, strlen($dateStr) - 1); } }
/** Return formatted date based on timestamp $d */ function adodb_date($fmt, $d = false, $is_gmt = false) { static $daylight; global $ADODB_DATETIME_CLASS; if ($d === false) { return $is_gmt ? @gmdate($fmt) : @date($fmt); } if (!defined('ADODB_TEST_DATES')) { if (abs($d) <= 0x7fffffff) { // check if number in 32-bit signed range if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) { // if windows, must be +ve integer return $is_gmt ? @gmdate($fmt, $d) : @date($fmt, $d); } } } $_day_power = 86400; $arr = _adodb_getdate($d, true, $is_gmt); if (!isset($daylight)) { $daylight = function_exists('adodb_daylight_sv'); } if ($daylight) { adodb_daylight_sv($arr, $is_gmt); } $year = $arr['year']; $month = $arr['mon']; $day = $arr['mday']; $hour = $arr['hours']; $min = $arr['minutes']; $secs = $arr['seconds']; $max = strlen($fmt); $dates = ''; $isphp5 = PHP_VERSION >= 5; /* at this point, we have the following integer vars to manipulate: $year, $month, $day, $hour, $min, $secs */ for ($i = 0; $i < $max; $i++) { switch ($fmt[$i]) { case 'T': if ($ADODB_DATETIME_CLASS) { $dt = new DateTime(); $dt->SetDate($year, $month, $day); $dates .= $dt->Format('T'); } else { $dates .= date('T'); } break; // YEAR // YEAR case 'L': $dates .= $arr['leap'] ? '1' : '0'; break; case 'r': // Thu, 21 Dec 2000 16:01:07 +0200 // 4.3.11 uses '04 Jun 2004' // 4.3.8 uses ' 4 Jun 2004' $dates .= gmdate('D', $_day_power * (3 + adodb_dow($year, $month, $day))) . ', ' . ($day < 10 ? '0' . $day : $day) . ' ' . date('M', mktime(0, 0, 0, $month, 2, 1971)) . ' ' . $year . ' '; if ($hour < 10) { $dates .= '0' . $hour; } else { $dates .= $hour; } if ($min < 10) { $dates .= ':0' . $min; } else { $dates .= ':' . $min; } if ($secs < 10) { $dates .= ':0' . $secs; } else { $dates .= ':' . $secs; } $gmt = adodb_get_gmt_diff($year, $month, $day); $dates .= ' ' . adodb_tz_offset($gmt, $isphp5); break; case 'Y': $dates .= $year; break; case 'y': $dates .= substr($year, strlen($year) - 2, 2); break; // MONTH // MONTH case 'm': if ($month < 10) { $dates .= '0' . $month; } else { $dates .= $month; } break; case 'Q': $dates .= $month + 3 >> 2; break; case 'n': $dates .= $month; break; case 'M': $dates .= date('M', mktime(0, 0, 0, $month, 2, 1971)); break; case 'F': $dates .= date('F', mktime(0, 0, 0, $month, 2, 1971)); break; // DAY // DAY case 't': $dates .= $arr['ndays']; break; case 'z': $dates .= $arr['yday']; break; case 'w': $dates .= adodb_dow($year, $month, $day); break; case 'l': $dates .= gmdate('l', $_day_power * (3 + adodb_dow($year, $month, $day))); break; case 'D': $dates .= gmdate('D', $_day_power * (3 + adodb_dow($year, $month, $day))); break; case 'j': $dates .= $day; break; case 'd': if ($day < 10) { $dates .= '0' . $day; } else { $dates .= $day; } break; case 'S': $d10 = $day % 10; if ($d10 == 1) { $dates .= 'st'; } else { if ($d10 == 2 && $day != 12) { $dates .= 'nd'; } else { if ($d10 == 3) { $dates .= 'rd'; } else { $dates .= 'th'; } } } break; // HOUR // HOUR case 'Z': $dates .= $is_gmt ? 0 : -adodb_get_gmt_diff($year, $month, $day); break; case 'O': $gmt = $is_gmt ? 0 : adodb_get_gmt_diff($year, $month, $day); $dates .= adodb_tz_offset($gmt, $isphp5); break; case 'H': if ($hour < 10) { $dates .= '0' . $hour; } else { $dates .= $hour; } break; case 'h': if ($hour > 12) { $hh = $hour - 12; } else { if ($hour == 0) { $hh = '12'; } else { $hh = $hour; } } if ($hh < 10) { $dates .= '0' . $hh; } else { $dates .= $hh; } break; case 'G': $dates .= $hour; break; case 'g': if ($hour > 12) { $hh = $hour - 12; } else { if ($hour == 0) { $hh = '12'; } else { $hh = $hour; } } $dates .= $hh; break; // MINUTES // MINUTES case 'i': if ($min < 10) { $dates .= '0' . $min; } else { $dates .= $min; } break; // SECONDS // SECONDS case 'U': $dates .= $d; break; case 's': if ($secs < 10) { $dates .= '0' . $secs; } else { $dates .= $secs; } break; // AM/PM // Note 00:00 to 11:59 is AM, while 12:00 to 23:59 is PM // AM/PM // Note 00:00 to 11:59 is AM, while 12:00 to 23:59 is PM case 'a': if ($hour >= 12) { $dates .= 'pm'; } else { $dates .= 'am'; } break; case 'A': if ($hour >= 12) { $dates .= 'PM'; } else { $dates .= 'AM'; } break; default: $dates .= $fmt[$i]; break; // ESCAPE // ESCAPE case "\\": $i++; if ($i < $max) { $dates .= $fmt[$i]; } break; } } return $dates; }
/** * Return the date using a particular formatting string. * * @param string $format Format code string. e.g. "d M Y" (see http://php.net/date) * @return string The date in the requested format */ public function Format($format) { if ($this->value) { $date = new DateTime($this->value); return $date->Format($format); } }
function set_post_content_34($entry, $form) { // Create flatterbox post object //Get the current user info to insert into flatterbox information $current_user = wp_get_current_user(); $current_user_name = $current_user->user_login; //Set up the flatterbox information to insert $my_flatterbox = array('post_title' => $entry["1"] . '\'s ' . $entry["26"] . ' Flatterbox', 'post_type' => 'flatterboxes', 'post_content' => '', 'post_status' => 'publish', 'post_author' => get_current_user_id()); // Insert the post into the database if (!isset($_SESSION["new_flatterbox_id"])) { $new_post_id = wp_insert_post($my_flatterbox); $newpid = $new_post_id; } else { $my_flatterbox = array('ID' => $_SESSION["new_flatterbox_id"], 'post_title' => $entry["1"] . '\'s ' . $entry["26"] . ' Flatterbox', 'post_content' => ''); wp_update_post($my_flatterbox); // To update the title $newpid = $_SESSION["new_flatterbox_id"]; } $_SESSION["occassion_name"] = $entry["26"]; wp_set_object_terms($newpid, $entry["26"], 'flatterbox_type', 0); //Convert date to ACF's format $date = new DateTime($entry["2"]); $newdate = $date->Format(Ymd); $boxtheme = ''; switch ($entry["26"]) { case 'Birthday': $boxtheme = $entry["27"]; break; case 'Anniversary': $boxtheme = $entry["28"]; break; case 'Military Gift': $boxtheme = $entry["53"]; break; case 'Get Well': $boxtheme = $entry["52"]; break; case 'Bar/Bat Mizvah': $boxtheme = $entry["51"]; break; case 'New Baby/Parents': $boxtheme = $entry["50"]; break; case 'Engagement': $boxtheme = $entry["49"]; break; case 'Wedding': $boxtheme = $entry["48"]; break; case 'Graduation': $boxtheme = $entry["47"]; break; case 'Bridal Shower': $boxtheme = $entry["46"]; break; case "Boss' Gift": $boxtheme = $entry["45"]; break; case 'Holiday': $boxtheme = $entry["44"]; break; case "Valentine's Day": $boxtheme = $entry["43"]; break; case "Father's Day": $boxtheme = $entry["42"]; break; case 'Sweet 16': $boxtheme = $entry["41"]; break; case 'Love You Because...': $boxtheme = $entry["40"]; break; case 'Retirement': $boxtheme = $entry["39"]; break; case 'Hanukkah': $boxtheme = $entry["38"]; break; case "Mother's Day": $boxtheme = $entry["37"]; break; case 'Funeral': $boxtheme = $entry["36"]; break; case 'New Year Encouragement': $boxtheme = $entry["80"]; break; case 'Just Because...': $boxtheme = $entry["34"]; break; case 'Divorce Encouragement': $boxtheme = $entry["33"]; break; case 'Corporate Meeting': $boxtheme = $entry["32"]; break; case "Teacher's Gift": $boxtheme = $entry["31"]; break; case 'Christmas': $boxtheme = $entry["30"]; break; case "Coach's Gift": $boxtheme = $entry["29"]; break; case "Coach's Gift": $boxtheme = $entry["29"]; break; case "Baby Shower": $boxtheme = $entry["81"]; break; } __update_post_meta($newpid, 'occasion', $value = $entry["26"]); $_SESSION["occasion"] = $entry["26"]; __update_post_meta($newpid, 'box_theme', $value = $boxtheme); $_SESSION["box_theme"] = $boxtheme; __update_post_meta($newpid, 'who_is_this_for', $value = $entry["1"]); $_SESSION["who_is_this_for"] = $entry["1"]; __update_post_meta($newpid, 'who_is_this_from', $value = $entry["65"]); $_SESSION["who_is_this_from"] = $entry["65"]; __update_post_meta($newpid, 'date_of_birthday', $value = $newdate); $_SESSION["date_of_birthday"] = $newdate; __update_post_meta($newpid, 'birthday_occassion', $value = $entry["3"]); $_SESSION["birthday_occassion"] = $entry["3"]; __update_post_meta($newpid, 'card_style', $value = $_SESSION["cardcolor"]); __update_post_meta($newpid, 'card_quantity', $value = $_SESSION["cardquantity"]); __update_post_meta($newpid, 'box_style', $value = $_SESSION["boxtype"]); __update_post_meta($newpid, 'introductory_card_message', $value = $entry["4"]); $_SESSION["introductory_card_message"] = $entry["4"]; __update_post_meta($newpid, 'special_instructions_to_flatterers', $value = $entry["77"]); $_SESSION["special_instructions_to_flatterers"] = $entry["77"]; __update_post_meta($newpid, 'private', $value = $entry["8"]); // Used for Passcode $_SESSION["private"] = $entry["8"]; __update_post_meta($newpid, 'can_invite', $value = $entry["69"]); // Used for Flaterers to be able to Invite $_SESSION["can_invite"] = $entry["69"]; __update_post_meta($newpid, 'allow_to_see_eachother', $value = $entry["25"]); $_SESSION["allow_to_see_eachother"] = $entry["25"]; __update_post_meta($newpid, 'allow_to_share', $value = $entry["7"]); $_SESSION["allow_to_share"] = $entry["7"]; __update_post_meta($newpid, 'allow_profanity', $value = $entry["9"]); $_SESSION["allow_profanity"] = $entry["9"]; __update_post_meta($newpid, 'notification_frequency', $value = $entry["10"]); $_SESSION["notification_frequency"] = $entry["10"]; __update_post_meta($newpid, 'total_price', $value = $_SESSION["totalprice"]); __update_post_meta($newpid, 'box_image_url', $value = $_SESSION["boxtypeimg"]); //$_SESSION["boxtypeimg"] __update_post_meta($newpid, 'box_color', $value = $_SESSION["boxcolor"]); //__update_post_meta( $newpid, 'title_card_headline', $value = $entry["73"]); // Removed from form __update_post_meta($newpid, 'live_event', $value = $entry["78"]); // Dates for Deadlines __update_post_meta($newpid, 'date_of_delivery', $value = $newdate); __update_post_meta($newpid, 'date_of_project_complete', $value = $newdate); __update_post_meta($newpid, 'date_sentiments_complete', $value = $newdate); //$current_user = wp_get_current_user(); //$uniquestart = $current_user->user_email.$newpid; //__update_post_meta( $newpid, 'unique_url', $value = md5(uniqid($uniquestart, true))); //Order Items __update_post_meta($newpid, 'order_count', $value = ''); __update_post_meta($newpid, 'add10', $value = '0'); // Only Update if new if (!isset($_SESSION["new_flatterbox_id"])) { __update_post_meta($newpid, 'unique_url', $value = getURLToken(10)); } // Dates for Deadlines //Convert dates to ACF's format $date = new DateTime($entry["2"]); $delivery = $date->Format(Ymd); $date = new DateTime($entry["19"]); // Was 19? Which doesnt exist $project = $date->Format(Ymd); $date = new DateTime($entry["54"]); $sentiment = $date->Format(Ymd); __update_post_meta($newpid, 'date_of_delivery', $value = $delivery); $_SESSION["date_of_delivery"] = $delivery; __update_post_meta($newpid, 'date_of_project_complete', $value = $project); $_SESSION["date_of_project_complete"] = $project; __update_post_meta($newpid, 'date_sentiments_complete', $value = $sentiment); $_SESSION["date_sentiments_complete"] = $sentiment; $_SESSION["new_flatterbox_id"] = $newpid; if ($entry["84"] == "1") { wp_redirect(site_url() . "/my-flatterbox/"); exit; } }
/** * Request media page children from the filtered date. */ public function dateFilter() { // Apply the from date filter. $request = $this->getRequest(); $from = $request->getVar('from'); $link = $this->Link(); $separator = '?'; if ($from) { // Determine the formatted URL to represent the request filter. $date = new DateTime($from); $link .= $date->Format('Y/m/d/'); } // Preserve the category/tag filters if they exist. $category = $request->getVar('category'); $tag = $request->getVar('tag'); if ($category) { $link = HTTP::setGetVar('category', $category, $link, $separator); $separator = '&'; } if ($tag) { $link = HTTP::setGetVar('tag', $tag, $link, $separator); } // Allow extension customisation. $this->extend('updateFilter', $link); // Request the filtered paginated children. return $this->redirect($link); }
/** * @group test * The get first charge test method. */ public function testGetFirstWhenConfigValidShouldGetTheFirstCharge() { date_default_timezone_set("UTC"); $testConfig = new TestServicesConfig(); $chargeSvc = new HpsCreditService($testConfig->ValidMultiUseConfig()); $dateFormat = 'Y-m-d\\TH:i:s.00\\Z'; $dateMinus10 = new DateTime(); $dateMinus10->sub(new DateInterval('PT10H')); $dateMinus10Utc = gmdate($dateFormat, $dateMinus10->Format('U')); $nowUtc = gmdate($dateFormat); $items = $chargeSvc->ListTransactions($dateMinus10Utc, $nowUtc, "CreditSale"); // HpsTransactionType::Capture $this->assertTrue(0 != count($items)); $charge0 = $items[0]->transactionId; $charge1 = $items[1]->transactionId; $this->assertNotNull($charge0); $this->assertNotNull($charge1); $this->assertNotEquals($charge0, $charge1); }
function isAffichable($abs, $date, $eleve) { $creneau_col = EdtCreneauPeer::retrieveAllEdtCreneauxOrderByTime(); $test_ouverture = false; foreach ($creneau_col as $creneau) { $datedebutabs = explode(" ", $abs->getDebutAbs()); $dt_date_debut_abs = new DateTime($datedebutabs[0]); $heure_debut = explode(":", $datedebutabs[1]); $dt_date_debut_abs->setTime($heure_debut[0], $heure_debut[1], $heure_debut[2]); $tab_heure = explode(":", $creneau->getHeuredebutDefiniePeriode()); $date->setTime($tab_heure[0], $tab_heure[1], $tab_heure[2]); //on verifie si le creneau est ouvert et s'il est posterieur au debut de l'absence if ($date->Format('U') > $dt_date_debut_abs->Format('U') && EdtHelper::isEtablissementOuvert($date)) { $test_ouverture = true; } } if ($test_ouverture && $abs->getManquementObligationPresence()) { return true; } else { return false; } }
public function testListTransactions() { date_default_timezone_set("UTC"); $config = TestServicesConfig::validMultiUseConfig(); $dateFormat = 'Y-m-d\\TH:i:s.00\\Z'; $dateMinus10 = new DateTime(); $dateMinus10->sub(new DateInterval('PT10H')); $dateMinus10Utc = gmdate($dateFormat, $dateMinus10->Format('U')); $nowUtc = gmdate($dateFormat); $transactions = $this->service->listTransactions()->withStartDate($dateMinus10Utc)->withEndDate($nowUtc)->withFilterBy("CreditSale")->execute(); $this->assertTrue(0 != count($transactions)); $charge0 = $transactions[0]->originalTransactionId; $charge1 = $transactions[1]->originalTransactionId; $this->assertNotNull($charge0); $this->assertNotNull($charge1); }
$delivery = $date->Format("m/d/Y"); } else { $delivery = ''; } ?> jQuery("#input_<?php echo $iForm; ?> _2").val('<?php echo $delivery; ?> '); <?php if (strlen($_GET['finalize']) > 0) { $date = new DateTime($_GET['finalize']); $sentimentdate = $date->Format("m/d/Y"); } else { $sentimentdate = ''; } ?> jQuery("#input_<?php echo $iForm; ?> _54").val('<?php echo $sentimentdate; ?> '); jQuery("#input_<?php echo $iForm; ?>
/** * Abort this job, potentially rescheduling a replacement if there is still work to do */ protected function discardJob() { $this->skipped = true; // If we do not have dirty records, then assume that these dirty records were committed // already this request (but probably another job), so we don't need to commit anything else. // This could occur if we completed multiple searchupdate jobs in a prior request, and // we only need one commit job to commit all of them in the current request. if (empty(static::$dirty_indexes)) { $this->addMessage("Indexing already completed this request: Discarding this job"); return; } // If any commit has run, but some (or all) indexes are un-comitted, we must re-schedule this task. // This could occur if we completed a searchupdate job in a prior request, as well as in // the current request $cooldown = Config::inst()->get(__CLASS__, 'cooldown'); $now = new DateTime(SS_Datetime::now()->getValue()); $now->add(new DateInterval('PT' . $cooldown . 'S')); $runat = $now->Format('Y-m-d H:i:s'); $this->addMessage("Indexing already run this request, but incomplete. Re-scheduling for {$runat}"); // Queue after the given cooldown static::queue(false, $runat); }