The time command on the redis-cli returns the current server time. How can I change the timezone on the redis server?
Note that redis gives me UTC+0300 timezone, whereas date on the Linux server shows me UTC+0700, which is my correct timezone.
Restarting the Linux server doesn't help.
Restarting the Linux server and restart redis-server doesn't help.
The Redis TIME command returns two values:
A Unix timestamp, in terms of seconds
A number of microseconds already passed within the value given by the first number
For example:
redis> TIME
1) "1674676800"
2) "123456"
That result represents 2023-01-25 20:00:00.123456 UTC.
Unix timestamps are always in terms of UTC, because they are defined as the number of seconds since 1970-01-01 00:00:00 UTC.
Thus, time zone is not reflected by the output of the TIME command at all. The number you see is not UTC+3, nor should it be UTC+7, it is just UTC.
If you are actually seeing a value that is three hours ahead of UTC, then your system's clock is set incorrectly - not your system's time zone. You should sync your clock with an NTP server to correct it.
You can check the UTC time on your Linux server from a bash prompt with date -u. You can also call date +%s to get a Unix timestamp, which should approximately match the first number returned by Redis.
Related
Currently my laravel config time zone is set to '+6:00' and MariaDB database time zone is set to SYSTEM, which is +6:00 as well. Now that I need to accommodate users from different time zones, I need to migrate all timestamp values to UTC to avoid any unintended time-related issues.
In MariaDB documentation it is stated that: https://mariadb.com/kb/en/timestamp/#time-zones
If a column uses the TIMESTAMP data type, then any inserted values are
converted from the session's time zone to Coordinated Universal Time
(UTC) when stored, and converted back to the session's time zone when
retrieved.
Now, this is where I am getting confused. What I understand from the above statement that I do not require to change anything in the database as timestamps are always stored in UTC no matter what is my session time zone is at the time of saving the data. Therefore, later on if I update my time zone to UTC in Laravel config, I should get the corresponding UTC value. But after changing the Time zone to UTC in Laravel config I am still getting the time in +6:00 format from eloquent model.
I think I am missing something here and would really appreciate any suggestion regarding this. Thanks in advance.
I am saving the Time Zone as 'Default[(UTC+05:30)Chennai, Kolkata, Mumbai, New Delhi]'. As the exact conversion of UTC to Local time is happening in client side (js).
While exporting the DateTime to an excel, I write the coding in appService itself. Due to time conversion is not happening in appService, I am getting the UTC time without converting to my time zone.
I have given date.tolocaltime(); for conversion while running in local source conversion is happening, but the conversion is not happening after hosting the application.
I have hosted my application on the cloud server (Azure)
CASE:
DateTime saved in DB - '2018-03-01 19:11:34.000'
Actual Date - '02-03-2018 00:43:22' (dd-mm-yyyy)
Showing Exported Date as - '2018-03-01'
Better you store time in UTC format in the database and show local time to the end user because it will be unique across all timezone so you will not have to worry about the locale of the user.
You have to options to do this.
Get time from the database and convert it to local time like this.
TimeZone.CurrentTimeZone.ToLocalTime(date);
Convert the UTC time to local time in Angular side before rendering
to the end user. I have already answered here.
I'm working on optimizing some functions in which I need to convert many timestamps to UTC. My need is to create a table with the columns as follows:
YEAR | TZ_NAME | Start of Daylight Savings | End of Daylight Savings
I can convert the timestamps easily using the from_tz function in oracle, however running this per timestamp isn't an option. Does anyone know how the oracle function works? I can't find any documentation that details where oracle keeps these daylight savings rules.
Any suggestions?
Thank you!
The time zone related information is stored in a file, as per: https://docs.oracle.com/cd/B19306_01/server.102/b14225/ch4datetime.htm#i1006667
The Oracle time zone files contain the valid time zone names. The
following information is also included for each time zone:
•Offset from Coordinated Universal Time (UTC)
•Transition times for Daylight Saving Time
•Abbreviations for standard time and Daylight Saving Time
I am actually using the mongDB API via a tLibraryLoad component, as I find this easier to build complex multi-level documents using tJavaRow and tJava components, than using the MongoDB palette components.
I am reading in data from Oracle which are date values with a zero time stamp component: For example:
29-JUN-08 00.00.00
The import works via Talend, however the records in mongo shell appear to be the previous day. You can see the record is inserted as the 28-JUN-2008.
Extract from JSON document in mongoDB:
"status_date" : ISODate("2008-06-28T23:00:00Z")
It is almost as if mongoDB (or Talend?) sees a midnight date as the end of the previous day, rather than the start of the 29th June 2008.
In my Talend schema I have specified the Oracle columns as Date types with a DB Type of Date also.
Any advice appreciated.
---UPDATE 1------
As only some dates are affected, it seems this is a DST adjustment in mongoDB to adjust perhaps the display to my local timezone, as the dates which are impacted are in the back half of the year in daylight saving time.
Is it adjusting the date due to the location of the mongo shell?
It is adjusting the date due to the location of the mongo server so all people using the mongo shell would get the same answers to date queries?
Would different people running different mongo queries on dates get different results based on their location, their DST kick in dates...i.e. you could imagine dates from the 1st November 2015, being counted as contributing to October 31st figures (at 23:00)....
i
I feel your pain - this is derived from MongoDB itself.
At issue is that MongoDB stores dates in UTC format by default.
https://docs.mongodb.org/manual/tutorial/model-time-data/
You can use Mongo's suggestion above but in this case you are storing just the date and not the time. I've used two solutions:
Don't bother storing dates as DATEs. Convert all your dates to %Y%m%d format and store them as integers. You can easily compare dates using $gt and $lte just using integers - just be sure to bring in your date using the same format and convert them back in your program later.
... or ...
Since in your case your date seems to be off by an hour, add an hour to it before you make your insert. It all depends on how long the timezone offset is to your local machine.
On linux you can see what the utc value is using:
date -u
I suppose you could change your local timezone on your machine to be UTC time and see what happens.
Personally, I've never had an issue with using the first approach. It's fast and ensures that I have what I want in there.
I think it is because of the timezone of your server. Try to remove the timezone from your date object and then insert it to the mongodb.
With moment.js you can create date without the timezone in such way:
var date = moment.utc("29-JUN-08 00.00.00", 'DD-MM-YYYY h.mm.s').format()
If I change the time zone of my local machine, will it affect the Oracle Scheduler's next run time??
schedule jobs run from the time on the system clock of the server, so changing the timezone changes the system clock and therefore the next scheduled time
From my experience, Oracle scheduler takes the timezone from the session, unless you specify a start date (TIMESTAMP WITH TIME ZONE). If you want to change the timezone of a scheduled job, use dbms_scheduler.set_attribute and give a new start_date with the timezone you want. Check by looking at the next run date in DBA_SCHEDULER_JOBS, which is also of type TIMESTAMP WITH TIME ZONE.