Update config.php
This commit is contained in:
parent
52e9012a14
commit
60ca514d5a
|
|
@ -57,34 +57,58 @@ if(!check_function_exists("get_config_value")) {
|
|||
}
|
||||
}
|
||||
|
||||
if(!check_function_exists("get_current_datetime")) {
|
||||
function get_current_datetime($options=array()) {
|
||||
$datetime = false;
|
||||
if(!check_function_exists("get_current_timestamp")) {
|
||||
function get_current_timestamp($options=array())
|
||||
$timestamp = time();
|
||||
|
||||
$config = get_config();
|
||||
$timestamp = time();
|
||||
$timeformat = get_value_in_array("timeformat", $config, "Y-m-d H:i:s");
|
||||
|
||||
// get timeformat
|
||||
$timeformat = get_value_in_array("timeformat", $config, "Y-m-d H:i:s");
|
||||
if(!array_key_empty("timeformat", $options)) {
|
||||
$timeformat = $options['timeformat'];
|
||||
}
|
||||
|
||||
// get time from NTP server
|
||||
if(!array_key_empty("timeserver", $config)) {
|
||||
if(loadHelper("timetool")) {
|
||||
$timestamp = get_server_time($config['timeserver']);
|
||||
}
|
||||
}
|
||||
|
||||
// set now time
|
||||
if(!array_key_empty("now", $options)) {
|
||||
try {
|
||||
$dateTimeObject = \DateTime::createFromFormat($timeformat, $options['now']);
|
||||
$dateTimeObject = DateTime::createFromFormat($timeformat, $options['now']);
|
||||
$timestamp = $dateTimeObject->getTimestamp();
|
||||
} catch(Exception $e) {
|
||||
$timestamp = strtotime($options['now']);
|
||||
}
|
||||
}
|
||||
|
||||
// adjust time
|
||||
if(!array_key_empty("adjust", $options)) {
|
||||
$timestamp = strtotime($options['adjust'], $timestamp);
|
||||
}
|
||||
|
||||
return $timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
if(!check_function_exists("get_current_datetime")) {
|
||||
function get_current_datetime($options=array()) {
|
||||
// get timeformat
|
||||
$timeformat = get_value_in_array("timeformat", $config, "Y-m-d H:i:s");
|
||||
if(!array_key_empty("timeformat", $options)) {
|
||||
$timeformat = $options['timeformat'];
|
||||
}
|
||||
|
||||
// get timestamp
|
||||
$timestamp = get_current_timestamp($options);'
|
||||
|
||||
// set datetime
|
||||
$datetime = date($timeformat, $timestamp);
|
||||
|
||||
return $datetime;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user