• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Best way to work with DatePicker?


Well-known member
What is the best way to work with date of the DatePicker?
I am trying to make possible to define a specific date when we set the "Close This Poll at". Just a date, not time.

I have a DatePicker and I filter the value of it this way:

'close_date' => XenForo_Input::DATE_TIME
If I pick a date like 2011-11-10 in the DatePicker, it gives me, when filtering, this value: 1320883200.

That's ok until I go editing a poll and it give me this:

Close this poll on Jan 1, 1970 at 1:33 AM

Because it uses the {xen:datetime $poll.close_date, absolute} in the template, to get the close date.
Do I have to change the XenForo_Input type or I have to change the {xen:datetime}?

To show the date to the user, it works with this:

$poll['close_date'] = ($poll['close_date'] != 0 ? XenForo_Locale::date($poll['close_date'], 'picker') : '');
But since the close_date it is managed by a XenForo template, and it uses the {xen:datetime} I do not want to change the way the close date it is displayed. Maybe changing the way the close_date it is write to the database...

Still can not figure how to solve this.


Active member
You could look at the XenForo_Visitor object to get the user's language and their date display format?

$visitor = XenForo_Visitor::getInstance();
$language = $visitor->getLanguage();
$closeDate = date($language['date_format'], $poll.close_date);