如何在joomla配置中根据时区保存joomla数据库中的当前时间?

时间:2016-08-09 13:50:33

标签: joomla

  

我想根据配置在joomla中保存当前时间   joomla服务器时区。因为我的主机提供商设置了时区   到非洲/开普敦,但我需要获得当前的时区时间   我设置了后端服务器配置的asia / kolkata。当我   使用Jdate类然后根据时区非洲/开普敦给出时间   如何根据joomla配置时间在joomla中获得时间   亚洲/加尔各答区。

1 个答案:

答案 0 :(得分:3)

//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 configuration
相关问题