根据joomla服务器时区的配置,我想在joomla中保存当前时间。因为我的主机提供商已经将时区设置为非洲/开普敦,但我需要获得时区亚洲/加尔各答的当前时间,我已经设置了后端服务器配置。当我使用Jdate类时,它根据时区非洲/开普敦给出时间,如何根据joomla配置时区亚洲/加尔各答获得在joomla的时间。
发布于 2016-08-10 04:16:27
//get Configuration of joomla site
$config = JFactory::getConfig();
//get offset of joomla like asia/kolkata
$site_offset = $config->get('offset');
//get instance of joomla JDate Class
$jdate=JFactory::getDate('now',$site_offset);
// first argument now give me current time-stamp you also can pass time-stamp
// second parameter is offset i.e. time zone like asia/kolkata
$jdate->format('Y-m-d H:i:s',true);
//get converted time as your joomla configurationhttps://stackoverflow.com/questions/38852676
复制相似问题