Manage date and time
Elxis sets timezone to UTC (Greenwitch time). All system dates are stored in UTC. The public shown dates can be displayed in a different timezone. More over a user can pick his desired timezone overwriting site default.
Elxis internal date time (UTC): 2010-12-25 08:23:10 Site public date time (Europe/Athens): 2010-12-25 10:23:10 User selected date time (Asia/Tokyo): 2010-12-25 17:23:10
The elxisDate class formats date and time and also handles conversions from system (Elxis/UTC) to local (site/user) time or the opposite. elxisDate instance can be called via eFactory like this:
There are 2 major methods to format dates.
Format a given unix timestamp to local or system datetime string by using strftime style format arguments.
Format a given datetime string to local or system datetime string by using strftime style format arguments. The given datetime should be in this format: YYYY-mm-dd HH:ii:ss
An other cool feature of elxisDate class is that you can display any datetime for any place of the world. Use worldDate method feeded by a datetime string in UTC, a timezone and your desired format.
elxisDate can optionally generate custom datetime strings for specific languages. There is an interface class named elxisLocalDate that can be used to provide custom date formatting. The classes that implements this interface are stored in this folder:
includes/libraries/elxis/date/
following this name pattern: {language}.date.php (el.date.php, fa.date.php, it.date.php, etc)
elxisLocalDate interface has the following methods:
The classes that implements the elxisLocalDate interface should be named by following this name pattern: elxisDate{language} examples: elxisDateel, elxisDatefa, elxisDateit, etc...
Many languages need custom date formatting. For example fa (Farsi) dates should follow the Jalaly calendar and not the Julian or the Gregorian one. Also fa has different symbols for the numbers.
English datetime (Gregorian): Saturday 25 December 2010 10:55:07
Farsi datetime (Jalaly with latin numbers): يكشنبه 04 دي 1389 10:58:17
Farsi datetime (Jalaly with jalaly numbers): يكشنبه ۰۴ دي ۱۳۸۹ ۱۰:۵۷:۱۹
Note that the year in Jalaly is 1389 and not 2010! The same for months and days.
For el (Greek) months names should be displayed differently when they used on dates. Lets take the Greek name for January (Ιανουάριος) as an example.
Without any conversion a typical date time string would be as follows:
17 Ιανουάριος 2011 (wrong)
But this is wrong in Greek, the month name should be displayed in its Geniki (Γενική) form. The elxisDateel interface will fix that:
17 Ιανουαρίου 2011 (correct)
You can create a date interface for ay language if you wish. elxisDate will auto-load the localized interface for the current language if exists. If not dates will be formatted using the general pattern.
Κατασκευάστε μηχανές που επεκτείνουν την αναζήτηση του elxis οπουδήποτε μπορείτε να φανταστείτε