Hi,
I am trying to get difference between current date time and a field(date time).
Timezone for date formatting: UTC
Date format: MM/D/YYYY HH:mm:ss.SSS
Date with nanoseconds format: MMM D, YYYY @ HH:mm:ss.SSSSSSSSS
Scripted Field:
if(!doc['job_start_time'].empty) return new Date().getTime() / 1000 - doc['job_start_time'].value.millis / 1000
job_start_time: 09/17/2020 02:07:35.379
I have set Output format: Human Readable
Whenever I am trying to get the difference It's showing +12 hours.
What I am doing wrong here? Please guide.
matw
(Matthias Wilhelm)
September 17, 2020, 3:36pm
2
Hi and welcome to our community
Might be a timezone issue, what's the offset of your timezone to UTC ?
Best,
Matthias
Hi, Thanks for the quick response.
May I know where can I find Offset information.
Screenshot:
matw
(Matthias Wilhelm)
September 17, 2020, 3:45pm
4
I was interested in the timezone you're living, whether the offset to UTC is +12, thx
Oh right.
My timezone is India Standard Time (UTC+5:30).
How can I get it in UTC so I will get correct difference.
Hi matw, I am new to ELK, would appreciate if you please guide me on this?
matw
(Matthias Wilhelm)
September 21, 2020, 7:31am
8
ahmadsayeed3:
getTime
Sure, sorry for the delay, so new Date().getTime()
should return UTC. So I would check 2 things:
Is the server where this is executed, Elasticsearch is running in the right timezone?
Is the raw timestamp stored in the Elasticsearch record in UTC?
Pretty sure this is a timezone issue, so first you've to check, if all component's timezone is correct.
Best,
Matthias
Strange behavior I have observed.
When running in day it's giving correct difference.
When I run at night, it gives 12 hours difference. I checked and all set UTC format.
I don't know where should I look next.
matw
(Matthias Wilhelm)
October 6, 2020, 8:31am
10
I'd suggest looking at the raw values of
ahmadsayeed3:
job_start_time
to find out when it this wrong difference is calculated. you say it's
09/17/2020 02:07:35.379
could it be is using the 12 hour clock instead of the 24 hour clock? this is just a wild guess, if e.g. it's wrong 0-12 and right 12-24 ...
Thanks matw.
That solved. The problem was cause of 12 hour clock.
24 hour clock working good.
system
(system)
Closed
November 5, 2020, 10:16am
13
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.