Welcome,
Guest
.
Please
login
or
register
.
Did you miss your
activation email
?
News:
Did you know that
Elxis 5.x
uses HTML5, CSS3 and pure javascript without external libraries such as jQuery?
Home
Help
Login
Register
Elxis CMS Forum
»
Support
»
General
(Moderators:
Ivan Trebješanin
,
Farhad Sakhaei
) »
About date & time
« previous
next »
Print
Pages: [
1
]
Author
Topic: About date & time (Read 4048 times)
armpouniotis
Sr. Member
Posts: 377
About date & time
«
on:
January 08, 2014, 15:02:37 »
Hi there !
I am using elxis 4.x
Inside the template header I am using:
$eDate = eFactory::getDate();
In body of the template within a <div> I want to display current date & time, and I am using:
<?php $eDate = strftime("%A, %d %b, %Y, | %H:%M"); echo $eDate; ?>
Date is displayed normaly, but unfortunately time is -2 hours...
What should I do to fix it ?
Thank you in advance
Christos
Logged
Christos Armpouniotis
datahell
Elxis Team
Hero Member
Posts: 10356
Re: About date & time
«
Reply #1 on:
January 08, 2014, 18:32:59 »
No, no, no, no, this is absolutely wrong.
$eDate is an instance of the
elxisDate
library class.
The fastest and easiest method to display the
current date
is this:
Code:
[Select]
$eDate = eFactory::getDate();
echo $eDate->formatDate('now');
To change the date format use one of the 13 built-in multi-lingual date formats:
DATE_FORMAT_1, DATE_FORMAT_2, ..., DATE_FORMAT_13
Example:
$eDate = eFactory::getDate();
$eLang = eFactory::getLang();
echo $eDate->formatDate('now', $eLang->get('DATE_FORMAT_8')); //example: Saturday Dec 25, 2010
Open the English main language file (
language/en/en.php
) and look at the top of the file the available formats.
Using
strftime
is bad as it depends on server default time zone. Elxis is much more advanced than this.
The date is automatically being displayed in your preferable
time zone
. Even guests can set a preferable time zone (in user's central).
If you haven't picked a time zone then the site's
default time zone
is used (see Elxis configuration).
elxisDate documentation
on Elxis Docs.
«
Last Edit: January 08, 2014, 18:39:08 by datahell
»
Logged
Elxis Team
|
Is Open Source
|
IOS Rentals | IOS AERO
armpouniotis
Sr. Member
Posts: 377
Re: About date & time
«
Reply #2 on:
January 09, 2014, 16:04:08 »
Thank you very much for your reply datahell !
that really works !
Logged
Christos Armpouniotis
Print
Pages: [
1
]
« previous
next »
Elxis CMS Forum
»
Support
»
General
(Moderators:
Ivan Trebješanin
,
Farhad Sakhaei
) »
About date & time