本文整理汇总了PHP中checkdate函数的典型用法代码示例。如果您正苦于以下问题:PHP checkdate函数的具体用法?PHP checkdate怎么用?PHP checkdate使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkdate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_pasien_check
function get_pasien_check($val) {
$val[tgl_periksa_tgl_start] = empty($val[tgl_periksa_tgl_start])?1:$val[tgl_periksa_tgl_start];
$val[tgl_periksa_bln_start] = empty($val[tgl_periksa_bln_start])?1:$val[tgl_periksa_bln_start];
$val[tgl_periksa_tgl_end] = empty($val[tgl_periksa_tgl_end])?1:$val[tgl_periksa_tgl_end];
$val[tgl_periksa_bln_end] = empty($val[tgl_periksa_bln_end])?1:$val[tgl_periksa_bln_end];
$objResponse = new xajaxResponse;
$tgl_start = strtotime($val[tgl_periksa_thn_start] . "-" . $val[tgl_periksa_bln_start] . "-" . $val[tgl_periksa_tgl_start]);
$tgl_end = strtotime($val[tgl_periksa_thn_end] . "-" . $val[tgl_periksa_bln_end] . "-" . $val[tgl_periksa_tgl_end]);
if(!checkdate($val[tgl_periksa_bln_start], $val[tgl_periksa_tgl_start], $val[tgl_periksa_thn_start])) {
$objResponse->addAlert("Tanggal Awal Tidak Valid");
$objResponse->addScriptCall("fokus", "tgl_periksa_tgl_start");
} elseif(!checkdate($val[tgl_periksa_bln_end], $val[tgl_periksa_tgl_end], $val[tgl_periksa_thn_end])) {
$objResponse->addAlert("Tanggal Akhir Tidak Valid");
$objResponse->addScriptCall("fokus", "tgl_periksa_tgl_start");
} elseif($tgl_start > $tgl_end) {
$objResponse->addAlert("Tanggal Awal Harus Kurang Dari Tanggal Akhir");
$objResponse->addScriptCall("fokus", "tgl_periksa_tgl_start");
} else {
$objResponse->addScriptCall("xajax_get_pasien", $val);
}
return $objResponse;
}
示例2: getDatesBetween
public function getDatesBetween($dStart, $dEnd)
{
if ($dStart > $dEnd) {
$var = $dStart;
$dStart = $dEnd;
$dEnd = $var;
}
$iStart = strtotime($dStart);
$iEnd = strtotime($dEnd);
if (false === $iStart || false === $iEnd) {
return false;
}
$aStart = explode('-', $dStart);
$aEnd = explode('-', $dEnd);
if (count($aStart) !== 3 || count($aEnd) !== 3) {
return false;
}
if (false === checkdate($aStart[1], $aStart[2], $aStart[0]) || false === checkdate($aEnd[1], $aEnd[2], $aEnd[0]) || $iEnd < $iStart) {
return false;
}
for ($i = $iStart; $i < $iEnd + 86400; $i = strtotime('+1 day', $i)) {
$sDateToArr = strftime('%Y-%m-%d', $i);
$sYear = substr($sDateToArr, 0, 4);
$sMonth = substr($sDateToArr, 5, 2);
//$aDates[$sYear][$sMonth][]=$sDateToArr;
$aDates[] = $sDateToArr;
}
if (isset($aDates) && !empty($aDates)) {
return $aDates;
} else {
return false;
}
}
示例3: printStk
function printStk($_POST)
{
# get vars
foreach ($_POST as $key => $value) {
${$key} = $value;
}
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($fday, "num", 1, 2, "Invalid from Date day.");
$v->isOk($fmon, "num", 1, 2, "Invalid from Date month.");
$v->isOk($fyear, "num", 1, 4, "Invalid from Date Year.");
$v->isOk($today, "num", 1, 2, "Invalid to Date day.");
$v->isOk($tomon, "num", 1, 2, "Invalid to Date month.");
$v->isOk($toyear, "num", 1, 4, "Invalid to Date Year.");
# mix dates
$fromdate = $fyear . "-" . $fmon . "-" . $fday;
$todate = $toyear . "-" . $tomon . "-" . $today;
if (!checkdate($fmon, $fday, $fyear)) {
$v->isOk($fromdate, "num", 1, 1, "Invalid from date.");
}
if (!checkdate($tomon, $today, $toyear)) {
$v->isOk($todate, "num", 1, 1, "Invalid to date.");
}
# display errors, if any
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class=err>-" . $e["msg"] . "<br>";
}
return $confirm;
}
# connect to database
db_connect();
// Layout
$report = "\n\t<h3>Non-Stock Sales Report</h3>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n <tr><th>Invoice no.</th><th>Date</th><th>Vat</th><th>SubTotal</th><th>Total</th></tr>";
# Get all relevant records
db_connect();
$sql = "SELECT * FROM salesrec WHERE edate >= '{$fromdate}' AND edate <= '{$todate}' AND typ = 'non' AND div = '" . USER_DIV . "'";
$recRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
$i = 0;
$tot = 0;
$totvat = 0;
$totexc = 0;
while ($rec = pg_fetch_array($recRslt)) {
# Calculate profit
$tot += $rec['total'];
$totvat += $rec['vat'];
$excvat = sprint($rec['total'] - $rec['vat']);
$totexc += $excvat;
$report .= "<tr class='" . bg_class() . "'><td>{$rec['invnum']}</td><td>{$rec['edate']}</td><td>" . CUR . " {$rec['vat']}</td><td>" . CUR . " {$excvat}</td><td>" . CUR . " {$rec['total']}</td></tr>";
$i++;
}
$tot = sprint($tot);
$totvat = sprint($totvat);
$totexc = sprint($totexc);
$report .= "<tr class='bg-even'><td colspan=2><b>Totals</b></td><td>" . CUR . " {$totvat}</td><td>" . CUR . " {$totexc}</td><td>" . CUR . " {$tot}</td></tr>\n\t</table>\n <p>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=15%>\n <tr><td><br></td></tr>\n <tr><th>Quick Links</th></tr>\n\t\t<tr class='bg-odd'><td><a href='sales-reports.php'>Sales Reports</a></td></tr>\n\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>";
return $report;
}
示例4: process_date_time
function process_date_time(&$d, $field, $type = "")
{
$month = $d["{$field}" . "_month"];
$day = $d["{$field}" . "_day"];
$year = $d["{$field}" . "_year"];
$hour = $d["{$field}" . "_hour"];
$minute = $d["{$field}" . "_minute"];
$use = $d["{$field}" . "_use"];
$valid = true;
/* If user unchecked "Use date and time" then time = 0 */
if (!$use) {
$d[$field] = 0;
return true;
}
if (!checkdate($month, $day, $year)) {
$d["error"] .= "ERROR: {$type} date is invalid.";
$valid = false;
}
if (!$hour and !$minute) {
$hour = 0;
$minute = 0;
} elseif ($hour < 0 or $hour > 23 or $minute < 0 or $minute > 59) {
$d["error"] .= "ERROR: {$type} time is invalid.";
$valid = false;
}
if ($valid) {
$d[$field] = mktime($hour, $minute, 0, $month, $day, $year);
}
return $valid;
}
示例5: isValid
public function isValid()
{
if ($this->year < 0 || $this->year > 9999)
return false;
return checkdate($this->month, $this->day, $this->year);
}
示例6: isValid
/**
* Validate a date.
*
* <code>
* $date = "01-01-2020";
*
* $validator = new Prism\Validator\Date($date);
*
* if (!$validator->isValid()) {
* ...
* }
*
* </code>
*
* @return bool
*/
public function isValid()
{
// Check for default SQL values.
$defaultDates = array('0000-00-00', '1000-01-01');
if (in_array($this->date, $defaultDates, true)) {
return false;
}
$string = trim($this->date);
if ($string === '') {
return false;
}
if (is_numeric($string)) {
$string = (int) $string;
if ($string === 0) {
return false;
}
$string = '@' . $string;
}
try {
$date = new \DateTime($string);
} catch (\Exception $e) {
return false;
}
$month = $date->format('m');
$day = $date->format('d');
$year = $date->format('Y');
if (checkdate($month, $day, $year)) {
return true;
} else {
return false;
}
}
示例7: VerifyTransactionDate
function VerifyTransactionDate($TranDate, $i, $Errors, $db)
{
$sql = "SELECT confvalue FROM config WHERE confname='" . DefaultDateFormat . "'";
$result = DB_query($sql, $db);
$myrow = DB_fetch_array($result);
$DateFormat = $myrow[0];
if (mb_strpos($TranDate, '/') > 0) {
$DateArray = explode('/', $TranDate);
} elseif (mb_strpos($TranDate, '.') > 0) {
$DateArray = explode('.', $TranDate);
}
if ($DateFormat == 'd/m/Y') {
$Day = $DateArray[0];
$Month = $DateArray[1];
$Year = $DateArray[2];
} elseif ($DateFormat == 'm/d/Y') {
$Day = $DateArray[1];
$Month = $DateArray[0];
$Year = $DateArray[2];
} elseif ($DateFormat == 'Y/m/d') {
$Day = $DateArray[2];
$Month = $DateArray[1];
$Year = $DateArray[0];
} elseif ($DateFormat == 'd.m.Y') {
$Day = $DateArray[0];
$Month = $DateArray[1];
$Year = $DateArray[2];
}
if (!checkdate(intval($Month), intval($Day), intval($Year))) {
$Errors[$i] = InvalidCurCostDate;
}
return $Errors;
}
示例8: cektgl
function cektgl($tanggal)
{
$tgl = substr($tanggal, 0, 2);
$bln = substr($tanggal, 3, 2);
$thn = substr($tanggal, 6, 4);
return checkdate($bln, $tgl, $thn);
}
示例9: reverseTransform
/**
* {@inheritdoc}
*/
public function reverseTransform($rfc3339)
{
if (!is_string($rfc3339)) {
throw new TransformationFailedException('Expected a string.');
}
if ('' === $rfc3339) {
return;
}
try {
$dateTime = new \DateTime($rfc3339);
} catch (\Exception $e) {
throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
}
if ($this->outputTimezone !== $dateTime->getTimezone()->getName()) {
try {
$dateTime->setTimezone(new \DateTimeZone($this->inputTimezone));
} catch (\Exception $e) {
throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
}
}
if (preg_match('/(\\d{4})-(\\d{2})-(\\d{2})/', $rfc3339, $matches)) {
if (!checkdate($matches[2], $matches[3], $matches[1])) {
throw new TransformationFailedException(sprintf('The date "%s-%s-%s" is not a valid date.', $matches[1], $matches[2], $matches[3]));
}
}
return $dateTime;
}
示例10: save
public function save(Gyuser_Model_BankAccounts $bank)
{
if (trim($bank->getOpening_date()) == '') {
$opening_date = null;
} else {
$dateArr = explode('/', $bank->getOpening_date());
if (checkdate($dateArr[1], $dateArr[0], $dateArr[2])) {
$stampeddate = mktime(12, 0, 0, $dateArr[1], $dateArr[0], $dateArr[2]);
$opening_date = date("Y-m-d", $stampeddate);
} elseif (checkdate($dateArr[0], '01', $dateArr[1])) {
//in case they have entered only month and year format ex: 02/1993
$stampeddate = mktime(12, 0, 0, $dateArr[0], '01', $dateArr[1]);
$opening_date = date("Y-m-d", $stampeddate);
} else {
throw Exception('The bank opening date is invalid.');
}
}
$data = array("user_id" => $bank->getUser_id(), "bank_name" => $bank->getBank_name(), "account_n" => $bank->getAccount_n(), "branch" => $bank->getBranch(), "opening_date" => $opening_date, "zip_code" => $bank->getZip_code(), "location_capital" => $bank->getLocation_capital());
if (null === ($id = $bank->getId())) {
unset($data['id']);
$id = $this->getDbTable()->insert($data);
return $id;
} else {
unset($data['user_id']);
$id = $this->getDbTable()->update($data, array('id = ?' => $id));
return $id;
}
}
示例11: validDate
private function validDate()
{
if (checkdate($this->month, $this->day, $this->year)) {
return true;
}
return false;
}
示例12: is_date
function is_date($value, $format = 'dd.mm.yyyy')
{
if (strlen($value) >= 6 && strlen($format) == 10) {
// find separator. Remove all other characters from $format
$separator_only = str_replace(array('m', 'd', 'y'), '', $format);
$separator = $separator_only[0];
// separator is first character
if ($separator && strlen($separator_only) == 2) {
// make regex
$regexp = str_replace('mm', '(0?[1-9]|1[0-2])', $format);
$regexp = str_replace('dd', '(0?[1-9]|[1-2][0-9]|3[0-1])', $regexp);
$regexp = str_replace('yyyy', '(19|20)?[0-9][0-9]', $regexp);
$regexp = str_replace($separator, "\\" . $separator, $regexp);
if ($regexp != $value && preg_match('/' . $regexp . '\\z/', $value)) {
// check date
$arr = explode($separator, $value);
$day = $arr[0];
$month = $arr[1];
$year = $arr[2];
if (@checkdate($month, $day, $year)) {
return true;
}
}
}
}
return false;
}
示例13: validate
/**
* {@inheritDoc}
*/
public function validate($value)
{
if (!preg_match('!(\\d+)-(\\d+)-(\\d+)!', $value, $matches)) {
return false;
}
return checkdate($matches[2], $matches[3], $matches[1]);
}
示例14: isDate
/**
* Will check if input date in format YYYY-MM-DD is valid.
*
* @param string $input Date string in format YYYY-MM-DD
* @return boolean TRUE if date is valid
*/
public static function isDate($input)
{
// split input date into params
list($year, $month, $day) = preg_split('/[-\\.\\/ ]/', $input);
// check date using builtin function
return checkdate($month, $day, $year);
}
示例15: isValid
public function isValid($value)
{
if (!is_string($value) && !is_int($value) && !is_float($value) && !is_array($value) && !$value instanceof Zend_Date) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($value);
if ($this->_format !== null || $this->_locale !== null || is_array($value) || $value instanceof Zend_Date) {
if (!Date::isDate($value, $this->_format, $this->_locale)) {
if ($this->_checkFormat($value) === false) {
$this->_error(self::FALSEFORMAT);
} else {
$this->_error(self::INVALID_DATE);
}
return false;
}
} else {
if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $value)) {
$this->_format = 'yyyy-MM-dd';
$this->_error(self::FALSEFORMAT);
$this->_format = null;
return false;
}
list($year, $month, $day) = sscanf($value, '%d-%d-%d');
if (!checkdate($month, $day, $year)) {
$this->_error(self::INVALID_DATE);
return false;
} else {
}
}
return true;
}