I use the jquery datepicker plugin to set the date field, which is stored as an epoch timestamp in db (the field, publish_time, maps directly to the table schema).
Datepicker seems to only support an era in milliseconds, not seconds. Compounding it is that it supports milli and nano seconds, but not seconds.
Are there any quick workarounds?
// Setup datepicker $('[name=datepicker-publish_time]').datepicker({ dateFormat : 'mm-dd-yy', altField : '[name=publish_time]', altFormat : '@' });
Literature:
jQuery Datepicker - http://jqueryui.com/demos/datepicker/#option-defaultDate
JQuery Support Date Formats - http://docs.jquery.com/UI/Datepicker/formatDate
Edit: Below is a quick dirty solution ...
$('[name=datepicker-publish_time]').datepicker({ dateFormat : 'mm-dd-yy', onSelect : function(dateText, inst) { var epoch = $.datepicker.formatDate('@', $(this).datepicker('getDate')) / 1000; $('[name=publish_time]').val(epoch); } });
jquery datepicker epoch
John himmelman
source share