CalcBuilder Forum

Use 'hour' in JDate

User veli 2017-09-27 08:49:34

have been trying to set a delivery date using current hour, because order we receive before 11.00 can be done next day, but after 11.00 I have to add a day extra.

I can not get it to work ... have tried this (and variants)

$date = JFactory::getDate();
$currentTime = new JDate ('now');
if ($currentTime ('H') >=11){
do something ...
} else {do something else}

I do not know how to select the current time from JDate, should be possible I guess?

Hope you can help, have tried searching internet but can't find an answer.


User veli 2017-09-27 09:11:13

Have found it ... apologies!

It works like this:
$date = JFactory::getDate();
$hour = $date->format('H');
if ($hour >=11){
do something etc.}


Create dynamic calculators

Buy now!
List Manager

Build different lists for your site

Buy now!