I'm using the following code to get and set a date meta value for a CPT in Gutenberg (some code omitted for brevity):

const [meta, setMeta] = useEntityProp(

const startDate = meta['_my_start_date'];

function onUpdateStartDate(value) {
    setMeta({ ...meta, '_my_start_date': value });


<PanelRow className="edit-activity-start-date">
    <span>{__('Activity Start Date', 'my-domain')}</span>
        placement="middle left"
        renderToggle={(({ isOpen, onToggle }) => (
            <Button isLink={true} onClick={onToggle} aria-expanded={isOpen}>
                {startDate ? dateI18n('j F, Y', startDate) : __('Pick a date', 'my-domain')}
        renderContent={() => (
                onChange={(newDate) => onUpdateStartDate(newDate)}

The thing is that the DatePicker component also stores the current time for the selected date (example: 2023-11-09T11:12:06). Is there a way to set the time in the DatePicker component to ZERO?

1 Answer 1


I managed to find the solution myself. You need to modify the onUpdateStartDate() function:

function onUpdateStartDate(value) {
    const date = new Date(value);
    date.setHours(0, 0, 0, 0);
    setMeta({ ...meta, '_my_start_date': date });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.