Automattic / Automattic/WP-Job-Manager
Issues with Scheduled Job Listings and Date Handling
- Dominant language
- PHP
- Stars
- 899
- Forks
- 369
- Avg merge
- 11h 37m
- Merged PRs (30d)
- 12
Description
**Describe the bug**
A user in 9588796-zd-a8c has reported issues with date/time handling when scheduling job listings in non-UTC timezones.
**1. post_date Field Incorrectly Adjusted for Timezone**
Issue: When scheduling job listings, post_date in the database incorrectly includes the timezone offset, causing jobs to display at an incorrect local time (e.g., 11 AM instead of midnight in Australia/Sydney UTC+11).
Cause: strtotime($maybe_date_string) assumes the input is UTC+0 and applies an offset incorrectly.
Expected Behavior: post_date should store local time, and post_date_gmt should be the correct UTC equivalent.
Suggested Fix: Modify maybe_format_future_datetime() to append the correct timezone offset before processing.
**2. post_date and post_date_gmt Incorrectly Matching**
Issue: When a scheduled date is set, post_date and post_date_gmt store the same value instead of differentiating local and GMT times.
Cause: Both fields are set to maybe_formatted_date instead of calculating post_date_gmt relative to local time.
Expected Behavior:
post_date: Local scheduled time.
post_date_gmt: Correct UTC time.
Affected Code: wp-job-manager-form-submit-job.php ([lines 1086-1096](https://github.com/Automattic/WP-Job-Manager/blob/trunk/includes/forms/class-wp-job-manager-form-submit-job.php#L1086)).
**3. jQuery Date Picker Lacks Time Selection**
Issue: The date picker does not allow users to set a time for job listings, defaulting to 00:00 UTC+0, which leads to incorrect local scheduling.
Expected Behavior: A datetime picker should be used to select both date and time, ensuring proper scheduling.
Suggested Fix: Replace the current jQuery date picker with a datetime picker (jQuery DateTime.js).
**To Reproduce**
Steps to reproduce the behavior:
1. Set timezone in general settings to UTC+11
2. Create a job listing and schedule it to be published on a future date.
3. Listing will be published at 11am (UTC+11) the next day instead of 00:00
**Isolating the problem (mark completed items with an [x]):**
- [x] I have deactivated other plugins and confirmed this bug occurs when only WP Job Manager plugin is active.
- [x] This bug happens with a default WordPress theme active.
- [x] I can reproduce this bug consistently using the steps above.
**WordPress Environment**
- WordPress Version: 6.7.2
- WP Job Manager Version: 2.4.0
- PHP Version: 8.2.28
Contributor guide
Research direction
Start with includes/forms/class-wp-job-manager-form-submit-job.php, especially lines 1086-1096, and reproduce scheduling with the WordPress timezone set to UTC+11. Trace how the date picker supplies its value and how post_date and post_date_gmt are assigned. Done means scheduled listings use the selected local date and time, store the correct UTC equivalent, and publish at the expected local time.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jquery, php
- Domain
- full-stack
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100