|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
samuel95_54 Smarty n00b
Joined: 24 Jan 2016 Posts: 3
|
Posted: Sun Jan 24, 2016 10:46 pm Post subject: Show different timezone |
|
|
I'm using smarty template engine right now.
I'm wondering how display date and time from different timezone. Presently I store the EX: SENT DATE, into the database on UNIX Time format on the GMT timezone.
When I want to display the SENT DATE I put this code in the .TPL file. Code: | {$message_search_result[i].MESSAGE_SENT_DATE|date_format:"$date_format %I:%M %p"} | This will output
Quote: | 25/06/2014 06:00 PM |
Inside the $date_format variable I have %d/%m/%Y
So how can I get this value to display depending on a selected timezone. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Jan 25, 2016 1:02 am Post subject: |
|
|
You must set necessary timezone before passing control to Smarty. |
|
Back to top |
|
samuel95_54 Smarty n00b
Joined: 24 Jan 2016 Posts: 3
|
Posted: Mon Jan 25, 2016 3:38 am Post subject: |
|
|
What I think i'm gonna do calculate each time zone difference in seconde from the GMT. So it's gonna look like this.
Code: |
{($message_search_result[i].MESSAGE_SENT_DATE$TIMEZONE)|date_format:"$date_format %I:%M %p"} |
In the variable $TIMEZONE i'm gonna put EX : -3600
Do you think it's the best way to do it? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
samuel95_54 Smarty n00b
Joined: 24 Jan 2016 Posts: 3
|
Posted: Mon Jan 25, 2016 12:48 pm Post subject: |
|
|
You were 100% right.
I wasn't know this function on php it's really easy integrate.
Thank a lot man you save me headache |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Jan 25, 2016 4:17 pm Post subject: |
|
|
Just make sure you are using UTC times internally.
Then converting them to any other timezone will not be a problem. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|