CalcBuilder Forum

Use 'hour' in JDate

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

Hi,
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.

Thanks!

Usuario 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.}

...
CalcBuilder

Create dynamic calculators

Buy now!
...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!