function strToTimestamp2($date, $format) { $decoded_date = strptimeEx($date, dateFormatToStrftime($format)); if ($decoded_date !== false) { return mktime($decoded_date['tm_hour'], $decoded_date['tm_min'], $decoded_date['tm_sec'], $decoded_date['tm_mon'] + 1, $decoded_date['tm_mday'], $decoded_date['tm_year'] + 1900); } else { return false; } }
function formulize_formatDateTime($dt) { // assumption is that the server timezone has been set correctly! // needs to figure out daylight savings time correctly...ie: is the user's timezone one that has daylight savings, and if so, if they are currently in a different dst condition than they were when the entry was created, add or subtract an hour from the seconds offset, so that the time information is displayed correctly. global $xoopsConfig, $xoopsUser; $serverTimeZone = $xoopsConfig['server_TZ']; $userTimeZone = $xoopsUser ? $xoopsUser->getVar('timezone_offset') : $serverTimeZone; $tzDiff = $userTimeZone - $serverTimeZone; $tzDiffSeconds = $tzDiff * 3600; if ($xoopsConfig['language'] == "french") { $return = setlocale("LC_TIME", "fr_FR.UTF8"); } return _formulize_TEMP_AT . " " . strftime(dateFormatToStrftime(_MEDIUMDATESTRING), strtotime($dt) + $tzDiffSeconds); }
function l_date($format, $date = FALSE) { $timestamp = $date ? $date : time(); return strftime(dateFormatToStrftime($format), $timestamp); }
/** * Render the Date field */ public function render() { global $icmsConfigPersona; $ele_name = $this->getName(); // ALTERED BY FREEFORM SOLUTIONS FOR THE DATE DEFAULT CHANGES IN FORMULIZE STANDALONE if ($icmsConfigPersona['use_jsjalali']) { include_once ICMS_ROOT_PATH . '/include/jalali.php'; } if ($this->getValue(false) !== _DATE_DEFAULT) { $ele_value = date(_SHORTDATESTRING, $this->getValue(false)); $jstime = formatTimestamp($this->getValue(false), _SHORTDATESTRING); if (_CALENDAR_TYPE == 'jalali') { $jalali_ele_value = icms_conv_nr2local(jdate(_SHORTDATESTRING, $ele_value)); } else { $jalali_ele_value = $ele_value; } } else { $ele_value = $this->getValue(false); $jstime = formatTimestamp(time(), _SHORTDATESTRING); $jalali_ele_value = $ele_value; } include_once ICMS_ROOT_PATH . '/include/calendar' . ($icmsConfigPersona['use_jsjalali'] == true ? 'jalali' : '') . 'js.php'; $result = "<input type='text' name='" . $ele_name . "' id='" . $ele_name . "' class=\"icms-date-box\" size='" . $this->getSize() . "' maxlength='" . $this->getMaxlength() . "' value='" . $ele_value . "'" . $this->getExtra() . " /> <img src='" . ICMS_URL . "/images/calendar.png' class='no-print' alt='" . _CALENDAR . "' title='" . _CALENDAR . "' id='btn_" . $ele_name . "' onclick='return showCalendar(\"" . $ele_name . "\");'>"; if (false and $icmsConfigPersona['use_jsjalali']) { $dateFormat = dateFormatToStrftime(_SHORTDATESTRING); $result = "<input name='" . $ele_name . "' id='" . $ele_name . "' class=\"icms-date-box\" size='" . $this->getSize() . "' maxlength='" . $this->getMaxlength() . "' value='" . $jalali_ele_value . "'" . $this->getExtra() . " /> <img src='" . ICMS_URL . "/images/calendar.png' class='no-print' alt='" . _CALENDAR . "' title='" . _CALENDAR . "' id='btn_" . $ele_name . "'><script type='text/javascript'>\n\t\t\t\tCalendar.setup({\n\t\t\t\t\tinputField : '" . $ele_name . "',\n\t\t\t\t\tifFormat : '{$dateFormat}',\n\t\t\t\t\tbutton : 'btn_" . $ele_name . "',\n\t\t\t\t\tlangNumbers : true,\n\t\t\t\t\tdateType : '" . _CALENDAR_TYPE . "',\n\t\t\t\t\tonUpdate : function(cal){document.getElementById('" . $ele_name . "').value = cal.date.print('{$dateFormat}');}\n\t\t\t\t});\n\t\t\t</script>"; } else { $result = "<input type='text' name='" . $ele_name . "' id='" . $ele_name . "' class=\"icms-date-box\" size='" . $this->getSize() . "' maxlength='" . $this->getMaxlength() . "' value='" . $ele_value . "'" . $this->getExtra() . " />"; static $output_datepicker_defaults = true; if ($output_datepicker_defaults) { $ICMS_URL = ICMS_URL; // the jQuery datepicker wants a date format such as yy-mm-dd, or yy-m-d. // yyyy-mm-dd gives a date like '20142014-10-11', so only yy, not yyyy. $dateFormat = dateFormatToStrftime(_SHORTDATESTRING); $dateFormat = str_replace(array("%y", "%m", "%d"), array("yy", "m", "d"), strtolower($dateFormat)); // note: datepicker_defaults is a var so it is available later for date elements with date limits $result .= <<<EOF <script> var datepicker_defaults = { dateFormat: "{$dateFormat}", changeMonth: true, changeYear: true, hideIfNoPrevNext: true, // do not show the prev/next links if they are disabled numberOfMonths: 1, yearRange: "c-20:c+20", showOn: "both", buttonImageOnly: true, buttonImage: "{$ICMS_URL}/images/calendar.png", buttonText: "Calendar" }; jQuery(document).ready(function() { jQuery.datepicker.setDefaults(datepicker_defaults); jQuery(function() { jQuery(".icms-date-box").datepicker(); }); }); </script> EOF; $output_datepicker_defaults = false; } } return $result; }