Moonsoft Software Solutions

Use 'hour' in JDate

Started 27 Sep 2017 · 1 reply

  1. veli
    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!
  2. veli
    Have found it ... apologies!

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

Still stuck?

Customers with an active license can open a support ticket.

Log in to open a ticket