Skip to content
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

Uncaught Exception: DateTime::__construct(): The timezone could not be found in the database #174

Closed
m1geo opened this issue Apr 1, 2018 · 3 comments

Comments

@m1geo
Copy link
Contributor

m1geo commented Apr 1, 2018

Hi folks. Issue in the latest commit. Cannot pass timezone. My timezone is BST:

m1geo@repeater:/var/log/$ date +"%Z %z"
BST +0100
m1geo@repeater:/var/log/$ date
Sun 1 Apr 23:18:35 BST 2018

The exact error in the CGI log is:

2018-04-01 22:31:56: (mod_fastcgi.c.2695) FastCGI-stderr: thrown in /opt/MMDVMHost-Dashboard/include/tools.php on line 116
2018-04-01 22:49:27: (mod_fastcgi.c.2695) FastCGI-stderr: PHP Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (ary file /opt/MMDVMHost) at position 0 (a): The timezone could not be found in the database in /opt/MMDVMHost-Dashboard/include/tools.php:116
2018-04-01 22:49:27: (mod_fastcgi.c.2695) FastCGI-stderr: Stack trace:
2018-04-01 22:49:27: (mod_fastcgi.c.2695) FastCGI-stderr: #0 /opt/MMDVMHost-Dashboard/include/tools.php(116): DateTime->__construct('ary file /opt/M...')
2018-04-01 22:49:27: (mod_fastcgi.c.2695) FastCGI-stderr: #1 /opt/MMDVMHost-Dashboard/include/functions.php(524): convertTimezone('ary file /opt/M...')
2018-04-01 22:49:27: (mod_fastcgi.c.2695) FastCGI-stderr: #2 /opt/MMDVMHost-Dashboard/include/functions.php(545): getHeardList(Array, false)
2018-04-01 22:49:27: (mod_fastcgi.c.2695) FastCGI-stderr: #3 /opt/MMDVMHost-Dashboard/include/init.php(13): getLastHeard(Array, false)
2018-04-01 22:49:27: (mod_fastcgi.c.2695) FastCGI-stderr: #4 /opt/MMDVMHost-Dashboard/index.php(25): include('/opt/MMDVMHost-...')
2018-04-01 22:49:27: (mod_fastcgi.c.2695) FastCGI-stderr: #5 {main}
2018-04-01 22:49:27: (mod_fastcgi.c.2695) FastCGI-stderr: thrown in /opt/MMDVMHost-Dashboard/include/tools.php on line 116

I guess this is following updates from the OS and the recently changed timezone (UTC to BST).

Thanks,
George M1GEO.

@m1geo
Copy link
Contributor Author

m1geo commented Apr 1, 2018

I had a quick poke around. Added a simple string printer to the convertTimezone(...):
echo("String: " . $timestamp . "<br>\n");

The following output shows the issue:

String: 2018-04-01 04:09:04.978
String: 2018-04-01 04:08:22.983
String: 2018-04-01 04:08:09.183
String: 2018-04-01 04:07:42.321
String: 2018-04-01 04:07:41.115
String: ary file /opt/MMDVMHost
[crash]

Clearly it cannot parse: "ary file /opt/MMDVMHost"

Not sure why this happens, or why it's trying to parse such a string?

George M1GEO

@m1geo
Copy link
Contributor Author

m1geo commented Apr 2, 2018

I fixed (think hacked!) it with a try and catch block:

function convertTimezone($timestamp) {
try {
$date = new DateTime($timestamp);
$date->setTimezone(new DateTimeZone(TIMEZONE));
return $date->format('Y-m-d H:i:s');
}
catch (Exception $err) {
//echo 'Error: ' . $err->getMessage();
}
}

@dg9vh
Copy link
Owner

dg9vh commented Apr 2, 2018 via email

@dg9vh dg9vh closed this as completed in 177d66f Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants