Need Help: Weird Issue with Timestamps & the Datepicker
-
Hello. I’ve run into an odd problem and have run out of ideas as to why this is occurring. I was hoping maybe someone has had this issue before and can point me in the right direction so I can clear this bug up.
I’m on cmb v2.9, the site is running on PHP 7.2.34 with WordPress 5.8.1, and I have tried disabling plugins, changing PHP versions, and all of the troubleshooting basics.
So, what’s actually happening. I’m using a metabox with a type => text_date_timestamp. When I use the datepicker to choose a date, it stores the date in the database with the correct timestamp(1630454400). When you view the post on the front-end, the date shows up correctly(September 1, 2021). However, if you edit the post, the datepicker will have the current month & day with the last 4 digits of the timestamp in place of the year(09/10/4400). This odd date issue also pops up when adding the metabox as a sortable column while browsing all posts of the post type.
I have also tried changing these to text_datetime_timestamp and get the same messed up dates in the back end.
Here is the code we use to set up the metabox:
$cmb_schedule->add_field(array( 'name' => 'Class Start Date', 'desc' => '<strong>Required</strong>', 'id' => $prefix . 'class_start_date', 'type' => 'text_date_timestamp', 'attributes' => array( 'required' => 'required', ), 'column' => array( 'position' => 2, ), ));
Thanks for taking the time to look at this for me and (hopefully) telling me where we screwed up.
- The topic ‘Need Help: Weird Issue with Timestamps & the Datepicker’ is closed to new replies.