Describe your bug or feature request.

When you create a promotion, the default start date is the current time and date in UTC, which for people in North America means that the promotion will be inactive on save.

If a bug, provide steps to reproduce it from a clean install.

Set the site and store timezones to a time in North America e.g. -400 (New York). Go to create a promotion and observe that the default Start Date is in the future, specifically the current time in UTC.

Comments

mandclu created an issue. See original summary.

bojanz’s picture

Promotion start/end dates are in the store timezone, not UTC.
Can you confirm that the timezone of your store is set properly?

Commerce doesn't use the site timezone because different stores can be in different timezones.

mandclu’s picture

Issue summary: View changes

Thanks for the suggestion. I checked and the store was indeed set to use the same timezone as the site, in my case -0400 (Toronto).

bojanz’s picture

Thanks for confirming.

Does the bug you're seeing mean that the promotion doesn't become active for customers at the given start date in the store timezone, or is it a UI bug where the default value for the start date in the admin UI isn't what you expect?

mandclu’s picture

It's the latter. As an admin, I would expect that if I don't alter the promotion's start date, it would start right away. Instead, the form is populated with a default value that seems offset by the timezone.

bojanz’s picture

Title: Promotion start date doesn't respect time zone » Promotion start date default value doesn't respect time zone

Understood.

Since a promotion can be available in multiple stores, we don't have access to a store and its timezone, but we can at least use the site timezone for the default value.

igor.barato’s picture

Status: Active » Needs review
StatusFileSize
new613 bytes

If we look the node "Authored On" field, it follows the Default site timezone.

I believe we can follow the same approach on Default start date value.

I replaced the gmdate() function by date() to work with the Site timezone.

Status: Needs review » Needs work

The last submitted patch, 7: commerce-promotions-3209414-7.patch, failed testing. View results

bsuttis’s picture

Status: Needs work » Needs review
StatusFileSize
new919 bytes
new1.5 KB

Here's a patch to change PromotionTest to use date() instead of gmdate().

Status: Needs review » Needs work

The last submitted patch, 9: promotion_start_date-3209414-9.patch, failed testing. View results

bsuttis’s picture

Status: Needs work » Needs review
StatusFileSize
new895 bytes
new2.37 KB

CouponTest too.

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

Customer was complaining that the start time shown on the add-promotion form was using the wrong timezone, after some debugging I worked out the problem was that neither the site nor store timezone was being used to convert the time generated from UTC, which lead me to search the issue queue for "promotion timezone", which lead me to this issue. And the patch solves the problem perfectly.

  • jsacksick committed ead89b7 on 8.x-2.x
    Issue #3209414 by bsuttis, igorbarato, DamienMcKenna: Promotion start...
jsacksick’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks.

  • jsacksick committed 0d2c4cf on 3.0.x
    Issue #3209414 by bsuttis, igorbarato, DamienMcKenna: Promotion start...
drumm’s picture

(Updating to fix Drupal.org issue indexing issue, please disregard.)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.