• I have a site used to schedule jobs for auto repair. It was running on an old server with an old PHP version 5.6. The Participants database plugin version was fairly old as well. When a job was scheduled, the scheduled date (a date field) could be entered with various formats such as Dec 25, 2022, or December 25, 2022 or 12/25/2022. The date was always displayed correctly, using the format under wordpress>settings>date format, when viewing any jobs.

    I since have moved everything to a new server running PHP 7.3 and currently V2.1.1 of the PDB. After a while we started realizing that dates that were entered as Dec. 25, 2022 or December 25, 2022 showed correctly. However dates entered as 12/25/2022 would display as December 24, 2022 in this date field. So they were getting entered as a day earlier than what was entered.

    I made the transition to the new server by creating a new site, installing PDB and the importing the records from the old site. This all seemed to work fine.

    I tried changing the date format in wordpress settings and that does display the format differently, but when creating a job and entering a scheduled date, anything still entered with a format such as 12/25/2022 is still getting scheduled a day early, 12/24/2022.

    I also added code from your blog that allows a record to be edited from the front end, so jobs can be “closed” when complete. That was done on the old server and new server, and although I don’t think that has anything to do with it, it is a change I made.

    Any help you could provide is greatly appreciated. thank you,

    bryan

    • This topic was modified 2 years, 4 months ago by bhinerdeer.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author xnau webdesign

    (@xnau)

    Generally speaking, date shifting happens because of a server configuration issue and a time zone difference bewtween the server and the WordPress install. The date will shift or not depending on the time of day that the date was submitted.

    The first suggestion I would make is don’t allow your users to choose the format for entered dates, this can lead to inconsistent results. A datepicker is a good way to achieve this, or you can use form validation to enforce it, giving them the expected format to use in the field’s help text.

    Second, you may benefit from the use of a plugin option that attempts to force php to use the WordPress timezone (as set in the WP settings) in some circumstances, the timezone will revert to the server’s timezone and this can result in a date shift. Try using the “Sync php Timezone” setting in the plugin settings under the advanced tab.

    Thread Starter bhinerdeer

    (@bhinerdeer)

    I enabled the “Sync php Timezone” setting as you suggested and this fixed the problem. All formats seem to work, but I will now set up form validation so only one format can be used. Thank You!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Date Field – the date is not always recorded correctly’ is closed to new replies.