2

I would like to check the time within a sub controller's method. The calendar field in my JForm saves the datetime to sql and uses UTC. So now we have 15:11h in Germany and in the database would be stored "2015-07-01 13:11:00".

Well, fine.

Now I'm using DATE_FORMAT_LC2 in my views to print the time in "German time". This works fine, too.

Now my controller wants to check if the entry is older than current time. Unfortunately I always get "2015-07-01 13:11:00", the time that is saved in the database, when calling $this->savedtime;

How can I "generate" the german time in my controller? At this moment this is my source:

$now            =           JFactory::getDate();            
$itemdate       =           JFactory::getDate($item->savedtime);

if($now > $itemdate)
{
//do fancy stuff
}

How can I solve this?

3

JHtml::date() will automatically use your timezone setting.

JHtml::date('now', 'Y-m-d H:i:s');

See the answer here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.