• R/O
  • SSH
  • HTTPS

ptiblogphp: Commit


Commit MetaInfo

Revision50 (tree)
Time2021-07-06 17:59:01
Authormateuszviste

Log Message

configurable timezone ($MYTIMEZONE)

Change Summary

Incremental Difference

--- trunk/changes.txt (revision 49)
+++ trunk/changes.txt (revision 50)
@@ -10,6 +10,7 @@
1010 - UI can be easily localized through settings (defaults to english)
1111 - format and language of timestamps are configurable
1212 - title string is properly htmlized (special characters escaped)
13+ - configurable timezone ($MYTIMEZONE)
1314 - improved css styling
1415
1516 ver 20210627
--- trunk/index.php (revision 49)
+++ trunk/index.php (revision 50)
@@ -20,6 +20,7 @@
2020 $TITLE = "MISSING TITLE";
2121 $DATELOCALE = 'en_US';
2222 $TIMESTAMPFORMAT = 'written %A, %B %e, %Y at %H:%M';
23+$MYTIMEZONE = '';
2324 // lang
2425 $LANG_USERNAME = 'username';
2526 $LANG_PASSWORD = 'password';
@@ -158,6 +159,9 @@
158159 // ustaw locale dla generowania dat
159160 setlocale(LC_TIME, $DATELOCALE);
160161
162+ // strefa czasowa dla obliczania lokalnych dat i godzin
163+ if (!empty($MYTIMEZONE)) date_default_timezone_set($MYTIMEZONE);
164+
161165 // czytaj zmienne przekazane via get
162166 $p = 0;
163167 $action = "";
@@ -213,7 +217,7 @@
213217
214218 // dodanie nowego wpisu? (albo edycja istniejącego)
215219 if (($isadmin) && ($action === 'dodajwpis')) {
216- if (empty($artid)) $artid = time();
220+ if (empty($artid)) $artid = time(); // notka: date_default_timezone_set() nie ma wpływu na time(), ten zawsze zwraca timestamp UTC (unix epoch)
217221 if ($artid < 0) {
218222 $dh = fopen('welcome.txt', 'w');
219223 fwrite($dh, trim($_POST['artbody']));
--- trunk/settings.php (revision 49)
+++ trunk/settings.php (revision 50)
@@ -7,6 +7,12 @@
77 $ADMINLOGIN = 'admin';
88 $ADMINPASS = '';
99
10+// you may enforce a specific timezone here so timestamps are displayed
11+// according to your timezone instead of the web server's system timezone.
12+// the timezone should be passed in the standard "IANA TZ DATABASE" format.
13+// Examples: Europe/Warsaw, America/New_York, Africa/Tripoli, Etc/GMT+5
14+$MYTIMEZONE = '';
15+
1016 // LOCALIZATION
1117 // adapt the phrases below to your language
1218 $LANG_USERNAME = 'username';
Show on old repository browser