Solr last_index_time difference timezone format so output is wrong - solr

Few days back I have started working on solr, and today I am facing a problem with deltaQuery.
my server timezone is IST also mysql is giving default output in IST.
but solr dataimport.properties file storing the timezone in UTC.
Problem is when I selecting the query B.modified_on >'${dataimporter.last_index_time}' then wrong time comparing because of timezone.
the solr logs are:- B.modified_on>'2016-09-23 07:39:10' and the server time is.
$ date
Fri Sep 23 15:22:20 IST 2016
Please suggest how to change solr timezone in IST or any other answer. I cann't my linux server timezone.

Solr logs by default are in UTC. To change this to IST, edit the solr.in.sh file to include the line:
# By default the start script uses UTC; override the timezone if needed
SOLR_TIMEZONE="IST"

You can use the CONVERT_TZ function in MySQL to convert a datetime field to UTC.
CONVERT_TZ(B.modified_on, 'IST', 'UTC') > '${dataimporter.last_index_time}'
.. should work. Try it in a MySQL command line session to see that you're getting the correct UTC time back.

Related

Date is saving one day less in react

I'm using react widget date picker. (https://jquense.github.io/react-widgets/docs/#/datetime-picker?_k=c0gioy)
I'm passing date in this format : Sat Jul 15 2017 00:00:00 GMT+0530 (IST)
I'm using laravel in server side.
But date is saving one day less. It's saving as 2017-07-14 in database.
Can anyone please tell me the reason ?
Thank you.
In your config file, set an env variable called APP_TIMEZONE with whatever timezone you want it to use
if you are dealing with database timezone, add DB_TIMEZONE in .env file and set its value to the timezone you want
EDIT
the backup solution (if none was found), would be to create a custom function that calculates the offset between the client timezone and the server timezone. then use it to save the appropriate date to the database.
an example:
function date_default_timezone_offset_get()
{
$offset = timezone_offset_get(new \DateTimeZone(date_default_timezone_get()), new \DateTime());
return sprintf("%s%02d:%02d", ($offset >= 0) ? '+' : '-', abs($offset / 3600), abs($offset % 3600));
}

Mongodb saves one day less - Time Zone Issue

I post date in the format from angular as MM/DD/YYYY but but when it saves in Mongodb it saves the ISO() format with one day less. I am developing using MEAN stack.
eg :(from angular ) 10/03/2016
mongodb : ISODate("2016-10-02T18:30:00.000Z")
I would like to resolve the timezone issue while saving the date in mongodb .
The MongoDB saves date time in UTC. So, it changes from IST to UTC before saving. IST offset is +05:30 from UTC. So your date time 10/03/2016 00:00:00 goes back 2016-10-02T18:30:00.000Z, the same date time in UTC.
You have to set the time back to IST while fetching the data from MongoDb before presenting to the client.
Btw you should try and save the datetime in ISO format from the beginning.
More here on the MongoDB doc page for Date

Is it possible to specify time zone for DB data source in PHPStorm?

I have UTC time zone set in my PostgreSQL and SELECT NOW() shows me the right date in psql console.
I use PHPStorm for development and its database console for accessing my database, but it uses different time zone (Europe/Moscow, which is the time zone of my Mac), and SELECT NOW() shows me the time in this time zone (and by the way, the date is wrong, because the Europe/Moscow time zone recently changed its offset to +3 from +4).
I have not found any information on how to tell PHPStorm to use the time zone configured in postgresql.conf instead of system's time zone. Is it possible?
verify your timezone with query
SELECT * FROM pg_timezone_names
now add phpstorm.vmoptions the config off timezone
-Duser.timezone=posix/America/Sao_Paulo
Apply changes, disconect, synchronize and verify whithselect now()
Well, I've found a solution, but it will affect every time-specific behavior in IDE, e.g. console logs will show datetime in UTC.
The idea is to pass a timezone to VM options. For that we need to modify a file and restart IDE.
For Mac OS X for the latest version of PHPStorm:
cp /Applications/PhpStorm.app/Contents/bin/phpstorm.vmoptions ~/Library/Preferences/PhpStorm2016.1/
Then add -Duser.timezone=UTC to the file, so that it looks something like that:
-Xms128m
-Xmx750m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops
-Duser.timezone=UTC
After phpstorm.vmoptions file modification with -Duser.timezone=UTC line I've seen correct return only from NOW() function but incorrect from the queries to a table like SELECT timestamp FROM ...
Only adding a variable timezoneAsRegion with false value to Advanced tab of connection without any phpstorm.vmoptions changes helped me to return correct timezone from the table.
Documentation link: https://www.jetbrains.com/help/phpstorm/2016.1/data-sources-and-drivers-dialog.html#advancedTab

Source of change in timestamp-format in default solr implementation

In Solr Index the format of my date-field is "2014-06-27T10:25:56.204Z" as expected. I can see this when calling: /solr/admin/luke?wt=xslt&tr=luke.xsl&fl=description&numTerms=200&docId=2
Anyhow the format of my date-field coming from Solritas (the default ResponseWriter) is Fri Jun 27 10:25:56 CEST 2014.
I can't find the location, where this transformation happens in order to change the format of the date-field according to my needs.
I haven't found the source of format change yet, but I know how to change the format anyhow:
#set($myDate = $doc.getFieldValue('myDate'))
$date.format("d. MMM. yyyy, h:mm",$myDate)

Excel Power Query - convert date time from UTC to Local

I'm connecting to an MS SQL database via Power Query (Version: 2.10.3598.81) in Excel 2010.
My dates are stored in UTC in the database, however I would like to show them as local in the spreadsheet.
DateTimeZone.From() - converts to a DateTimeZone type but assumes the input date is in the Local timezone. This is the exact opposite of what I want.
DateTimeZone.ToLocal() - gives an error, I think because there's no timezone information in the source date.
Local in my case is Australian EST, however it would be great if Excel just picked up the local timezone. (It appears to do this already)
I think I've discovered the answer.
The function DateTime.AddZone() which I thought was used to convert between timezones is actually used to add timezone information to an existing date. If your date is UTC you would use DateTime.AddZone([date_created],0) and if your date was already in AEST then you would use DateTime.AddZone([date_created],10).
So I can now use:
DateTimeZone.ToLocal(DateTime.AddZone([date_created_UTC],0))
and Power Query will correctly convert my date created from UTC to AEST (or whatever is local).

Resources