Italian (Italy)

Displays a calendar field to pick dates and times.

type

(string)  Must be equals to date.

label

(string)  The label to display next to the field.

help

(string)  An optional text to describe the purpose of the field.

required

(bool)  Whether the field is mandatory or optional.

value

(string)  The date to select.

id

(string)  An optional field ID.

class

(string)  An optional field class suffix.

hidden

(bool)  True to avoid displaying the label of the field.

attributes

(array)  An associative array containing additional calendar options.

  • onChange - the javascript callback to invoke after picking a date;
  • showTime - whether the field should allow the selection of the time too (false by default).

The format of the date is always equals to the one specified from the global configuration of VikRestaurants. The time is rather always display using the 24H format. The value of the date can be specified in 3 different ways.

Pre-Formatted Date

It is possible to manually pre-format the date according to the format accepted by the system.

$value = VikWPHtml::_('date', '2022-03-01 10:00', VREFactory::getConfig()->get('dateformat'));

Date Object

Construct a date object adjusted to the local timezone of the currently logged-in user.

$value = VikWPFactory::getDate('2022-03-01 10:00', VikWPFactory::getUser()->getTimezone());

Timestamp

This technique is discouraged because the system will reformat the specified timestamp according to the server timezone.

$value = mktime(10, 0, 0, 3, 1, 2022);
[
    'reminder' => [
        'type' => 'date',
        'label' => 'Reminder',
        'value' => VikWPFactory::getDate('2022-03-10 10:00', VikWPFactory::getUser()->getTimezone()),
        'attrs' => [
            'showTime' => true,
         ],
    ]
]

Changelog

Version Description
1.3 Introduced.
Ultimo aggiornamento: 2023-12-19
Utile?