Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Get timezone in Smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
vkrox
Smarty Rookie


Joined: 12 Jul 2018
Posts: 5

PostPosted: Tue Jul 24, 2018 7:30 am    Post subject: Get timezone in Smarty Reply with quote

Hi,

I want to get Europe London time with smarty. Please help me
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Jul 25, 2018 3:38 pm    Post subject: Reply with quote

Define "get"? Display current time in a given timezone? Convert specific time to a given timezone?

In both cases, you'd need a custom modifier for that.

Something along the lines of
Code:
$nf = new \NumberFormatter("ru_RU", \NumberFormatter::CURRENCY);
$cs = ini_get('output_encoding') ?: ini_get('iconv.output_encoding') ?: ini_get('default_charset') ?: 'ISO-8859-1';
$tpl->registerPlugin('modifier', 'price',
  function($price, $currency = 'RUB')
  use($nf, $cs)
  {
    return iconv('UTF-8', "$cs//IGNORE", $nf->formatCurrency($price, $currency));
  }
);
unset($nf, $cs);
but using DateTime/DateTimeFormatter/DateTimezone.
Back to top
View user's profile Send private message
vkrox
Smarty Rookie


Joined: 12 Jul 2018
Posts: 5

PostPosted: Wed Jul 25, 2018 4:12 pm    Post subject: Reply with quote

I want to get the current UK time with smarty
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Jul 27, 2018 1:48 am    Post subject: Reply with quote

vkrox wrote:
I want to get the current UK time with smarty

AnrDaemon wrote:
Define "get"?
Back to top
View user's profile Send private message
vkrox
Smarty Rookie


Joined: 12 Jul 2018
Posts: 5

PostPosted: Fri Jul 27, 2018 1:50 am    Post subject: Reply with quote

means, display UK time and need that uk time in a variable
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Jul 27, 2018 1:58 am    Post subject: Reply with quote

Assign all values to Smarty in your own code.
And use custom formatter to display it.
Back to top
View user's profile Send private message
vkrox
Smarty Rookie


Joined: 12 Jul 2018
Posts: 5

PostPosted: Fri Jul 27, 2018 1:59 am    Post subject: Reply with quote

but the code you have given is for currency right? i need to get the current time of UK
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Jul 27, 2018 3:57 am    Post subject: Reply with quote

Do you seriously expect me to do your job for you? For free, none the less?
I gave you the principle, it's not a rocket science to modify a working code for your own case.
Especially not since all intl classes follow the same suit.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP