gambitph / Titan-Framework

The easiest to use WordPress option framework.
http://www.titanframework.net
380 stars 137 forks source link

Date option default expects timestamp, docs state Y-m-d formatted string #408

Closed TreyOverton closed 6 years ago

TreyOverton commented 6 years ago

This works:

$tab->createOption([
    'name' => 'Report Date',
    'id' => 'hidden-report-date',
    'type' => 'date',
    'default' => time()
]);

This does not:

$tab->createOption([
    'name' => 'Report Date',
    'id' => 'hidden-report-date',
    'type' => 'date',
    'default' => date('Y-m-d')
]);

Documentation example is 'default' => '2010-12-20',, found here: http://www.titanframework.net/docs/date/

Using the documented technique for a default always produces a date of 1970-01-01 (timestamp 0).

mrjk990 commented 6 years ago

@AaronOverton you should use date function like this date('Y-m-d', time()) Reference: http://php.net/manual/en/function.date.php

$tab->createOption([
    'name' => 'Report Date',
    'id' => 'hidden-report-date',
    'type' => 'date',
    'default' => date('Y-m-d', time())
]);
juyal-ahmed commented 6 years ago

This pull request has the support for that date format default input with a couple of other update. https://github.com/gambitph/Titan-Framework/pull/410

bfintal commented 6 years ago

@tojibon Can you resubmit the PR for the date issue only?