New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set default time zone for date #154
Conversation
HOTFIX RELEASE 1.4.2
this prevents basic error messages from php(-cgi) for not setting the timezone and then using UTC as default
Not an error I've come across before, but I will test this and see if it breaks anything! |
I'm testing this now, to make sure that it doesn't force the timezone to be UTC if the server timezone is different. |
While it does not affect |
this will imply the system time zone. command date and the given format are supported by the majority of linux distros
trim against leading space from %k (range of ' 0' to '23') and strtolower for AM/PM that %p outputs as uppercase, while 'a' (-> am/pm) was used before
@Mcat12 So far I was not able to find a single solution to get the correct system time zone on most of the common linux distros within php. In addition there are incompatibilities between the output of the system and php. CEST for example can't be used by php and it's |
Looks great! Just one more thing. |
@@ -125,7 +125,7 @@ function getAllQueries() { | |||
$hostname = trim(file_get_contents("/etc/hostname"), "\x00..\x1F"); | |||
|
|||
foreach ($dns_queries as $query) { | |||
$time = date_create(substr($query, 0, 16)); | |||
$time = exec("date --date='" . trim(substr($query, 0, 16)) . "' +'%Y-%m-%d\%Z%H:%M:%S'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this use the same format as before? Y-m-d\TH:i:s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure! I thought the Timezone (T
in php date) is used here and forgot about the function of the \
^^
just output a 'T' insted of the Timezone
@das7pad had to revert this back out of the release, as it was causing issues. Happy to revisit, but we need to work out what it is doing to slow down the query page! |
After looking over this change, I've got some concerns with making exec commands in the script, especially within iterators. In general it's a bad idea and I think we might be able to achieve the same result without needing to use exec. I'm happy to refactor this if there's no objection. |
Suggestions and contributions always welcome! |
Unless they're rubbish... ;) |
Well forget it then. My default setting is "rubbish". :-) |
ok, I can understand the performance issue here. However not setting the timezone will spam the logfiles. What about setting the timezone on a first run? |
So there are a couple solutions to this problem.
I don't think the TZ should be stored in the Admin code base since it's based on the tz of the log file the backend is generating. I'm not sure that putting the effort in to a Admin UI setting is worth it since it will only be set once and should probably be done during install. |
@akoebbe The option in the dashbord later on would be just a call on the 'firstrun page' - which verifys the input and prints the timezone into another file, the admin scripts are then calling. Printing into the code of |
@das7pad Where would you suggest the value selected be stored? |
@das7pad We could check for the timezone with the getter function you mentioned and use the '@' to suppress warning messages on that call. |
@akoebbe How about the I am running Centos 7 and my Timezone is set to |
@pi-hole/dashboard
this prevents basic error messages from php(-cgi) for not setting the
timezone and then using UTC as default