public static mktime ( $hour, $minute, $second, $month, $day, $year, $jalali = null, $timezone = null ) : integer | ||
$hour | int Hour based on 24 hour system | |
$minute | int Minutes | |
$second | int Seconds | |
$month | int Month Number | |
$day | int Day Number | |
$year | int Four-digit Year number eg. 1390 | |
$jalali | bool (Optional) pass false if you want to input gregorian time | |
$timezone | string (Optional) acceps an optional timezone if you want one | |
return | integer | Unix Timestamp (Epoch Time) |
public static function mktime($hour, $minute, $second, $month, $day, $year, $jalali = null, $timezone = null)
{
//Defaults
$month = intval($month) == 0 ? self::date('m') : $month;
$day = intval($day) == 0 ? self::date('d') : $day;
$year = intval($year) == 0 ? self::date('Y') : $year;
$hour = intval($hour);
$minute = intval($minute);
$second = intval($second);
//Convert to Gregorian if necessary
if ($jalali === true || $jalali === null && self::$jalali === true) {
list($year, $month, $day) = self::toGregorian($year, $month, $day);
}
//Create a new object and set the timezone if available
$date = $year . '-' . sprintf('%02d', $month) . '-' . sprintf('%02d', $day) . ' ' . $hour . ':' . $minute . ':' . $second;
if (self::$timezone != null || $timezone != null) {
$obj = new DateTime($date, new DateTimeZone($timezone != null ? $timezone : self::$timezone));
} else {
$obj = new DateTime($date);
}
//Return
return $obj->format('U');
}
public static function mktime($hour, $minute, $second, $month, $day, $year, $jalali = null, $timezone = null) { return jDateTime::mktime($hour, $minute, $second, $month, $day, $year, $jalali, $timezone); }