Catalog Price Rules are set in the past - magento

I have a very weird problem with Catalog Price Rules. As you know normally when price rules are applied, they are applied for current day, past day, and next day.
The problem is that the price rules are generated only for current day, and two past days.
So if taking today example on catalogrule_product_price on rule_date row the dates set are:
2014-03-12
2014-03-13
2014-03-14 - today date
Instead of:
2014-03-13
2014-03-14 - today date
2014-03-15 - tomorrow
Any suggestions?

This happens when your database is using a different time zone to your Magento site. You need to check and verify that they are both using the same time zone.
For Magento you can check this from System -> Configuration -> Locale Options.
For your database, you can run the following query to the the current local time: SELECT NOW();
If these don't match then you will get the behaviour described above (rules are not correctly set +/- current day). Most likely you need to correct the timezone that your database is using.
Edit: it seems that the best way to handle this is to ensure that you set the global timezone to UTC in Magento, and then set the timezone for your individual site(s) to the local time in your region. Your database should also be set to default to UTC.
Edit 2: Also make sure that the default locale set in app/etc/config.xml is correct.

Could it be related to time zones? Either the time zone of your server clock or the time zone set in Magento?

Try setting your Default Store Timezone to match your server timezone.

Related

Why selecting a date\time range into Kibana the query is performed with wrong dates? URL parameters are wrong

I am working on a project involving ElasticSearch and visualizing data on Kibana and I am finding the following problem with date range selection.
As you can see in the following picture I selected I time range that starts from April 8 2021 at 00:00:00.000 and end at April 10 2021 00:00:00.000 . Then I clicked the Refresh button in order to perform the query.
The problem is that, as you can see in the highligher URL section the passed date range into the query is wrong !!! Infact this is the timerange section of my query into my URL parameters:
time:(from:'2021-04-07T22:00:00.000Z',to:'2021-04-10T10:00:00.000Z')
As you can see it is pretty differnt from what I selected into the start and end date form fields.
Changing the values into the start and end date form fields automatically changes also the values into the URL parameters but they still wrong.
What could be the problem? Why selecting dates and time into these form fields the parameters value are wrong? What could be the cause of this issue? How can I try to fix it?
I suspect something related to the server timezone (the server where Elastic\Kibana) are installed or something related to some Kibana configuration but I really have no idea
The kibana docs specify:
The timezone that Kibana uses. The default value of Browser uses the timezone detected by the browser.
So (I'm assuming) your browser default timezone is UTC + 2, meaning when you select 00:00 it's converted to 22:00 UTC timezone, The Z in 2021-04-07T22:00:00.000Z is in indicator here.

Microsoft PowerAutomate

I am currently building an out of office workflow in Microsoft powerautomate for Teams. When a request for 8/19/20 gets submitted it gets changed to 8/20/20 and same thing with the end date. Is there a way to set a it so it shows the actual dates selected?
So i think this is happening due to Default UTC time zone is used by Power Automate. Here is a flow that uses the Convert time zone action with a base time of utcNow(). Convert the time to needed timezone and then used an Update item action to update a date field with that converted time value. The correct time shows up in my SharePoint list
Hope this may help you.

Control UTC time in server side Dynamicscrm

I saved a record in 17:16:15, I run a job which gets the ModifiedOn field of my record and I got- 15:16:15, my GMT is +2, I want to know how to fix that gap that my result will turn out like it should be - 17:16:15. I can't select it from DB I need a solution in server side (c# I mean) what can U do in that case?
DateTimes are always saved in UTC in the database. *
You need to dynamically convert from UTC into your local time zone. In C#, you can do this with the .ToLocalTime() method as long as your code is running in the correct time zone. You can also find your local time in the FormattedValues collection of the response, which uses your Dynamics timezone user settings . But the raw datetime value in the database will always be in UTC.
* The only exception to this is if the DateTime field is set to “TimeZone Independent” in the attribute type settings. But be careful: once you set this option you can’t change it for that field again.

Laravel: How to deal with dates in different timezones

A lot of questions have been asked about this subject. The best answer that I found is this one: How to set local timezone in laravel
So the main rule is to keep all database entries in the same timezone.
But I have a specific case where this answer does not work for me. For some models, I have only a date (no datestamp). Example: suppose that I only store the date of when this question was asked (= 2018-01-25). However in Europe it is already 2018-01-26. Someone has a solution for this?
Changing my date field to a datestamp? What with existing dates?
You can use this library jamesmills/laravel-timezone
OR
If you need custom configuration:
Configure your app timezone to UTC.
'timezone' => 'UTC',
You can store different timezones in database column.
When outputting/displaying dates, just format it to use that timezone.
$timezone = 'America/Vancouver';
$model->created_at->setTimezone($timezone);
created_at and updated_at are automatically converted to carbon instances, which makes this easier. If you have other dates that you're using, add them to the protected $dates array on the model and laravel will convert them to carbon instance too. Then you can use carbons setTimezone() to change the date/time to the timezone.
If you're only talking about a date, then there is no time component and thus time zones are irrelevant. For this reason, most platforms do not have a separate date-with-zone type.
You're correct that not every time zone experiences the same date at all times, and that the start of a date and the end of the date occur at different times in different time zones. However, did you notice that in the prior sentence that I had to use the word "time" to rationalize about these points? :-)
Because date and time zone don't come together without time, there's no purpose in keeping them in the same field. Instead, keep two fields in your model - one for the date, and one for the time zone. In many cases, you may even find they belong in two different models.
As a use case example, consider birthdays. Mine is 1976-08-27. That's all it is - just a date. The time zone of my birth is irrelevant, and so is the time zone I'm located in - until I want to evaluate whether it's currently my birthday (or how long until my birthday, etc.) For those operations, my current time zone is important, and so is the start time-of-day and end time-of-day of that time zone. Thus - two different fields.

Rails 3.1 - timestamps in model and delayed time

I have generated a model in my Rails app (3.1) and I have a problem about saving the time into the DB table (through timestamps). The time is delayed of one hour. Exist any global solution of set up the time for timestamps?
Thanks in advance
I think the timestamps will always be saved in the database in UTC format. It's when you display them that they should be translated in the desired timezone.
To change the default timezone of your app: config.time_zone = "UTC".
You can find all timezones here: http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html

Resources