Kibana: how to convert {{date}} in not UTC format - datetime

Elastic/kibana. I created a alert rule and try to use {{date}} (or {{context.date}}) in my emails.
Right now I am getting the date and time in UTC format like this: 2023-02-01T08:30:59.069Z
How to convert this datetime to another format in local timezone (+2): 2023-02-01 10:30?
I used: {{dateVar | dateformat="MM/dd/yyyy"}}, {{sysdate}} and another methods but...

If you are observing your data from Kibana you can update the timezone and time format from:
Stack management => Advanced Settings

Related

Nifi convert UTC to unix time

I have a flowfile attribute which is a UTC datetime in the format of yyyy-MM-dd HH:mm:ss.SSS
I need to convert this to a unix timestamp.
How can this be done? I know its possible to convert Unix to the above format using Jolt:
"time": "${time:format('yyyy-MM-dd HH:mm:ss.SSS')}"
however, im not sure how to do this in reverse?
Working with attributes in this way uses the NiFi Expression Langauge (not Jolt).
See the docs here https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html
${time:format('yyyy-MM-dd HH:mm:ss.SSS')}
Uses Expression Language to format the time attribute to the given SimpleDateFormat string.
${time:toNumber()}
Uses Expression Language to convert the given Date object to Epoch Millis.
https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#tonumber

How to change UK date format in LogicApp

Im trying to convert a U.K. input date (dd-MM-yyyy) to format (yyyy-MM-dd)
I tried
"#formatDateTime('15-03-2019','yyyy-MM-dd')" ==> Error
but got error:
'In function 'convertTimeZone', the value provided
for date time string '15-03-2019' was not valid. The datetime
string must match ISO 8601 format.'
How do I go about converting this input date? The input format is (dd-MM-yyyy) and cannot be changed.
I can easily convert from (MM-dd-yyyy) as shown below, but im not able to convert from (dd-MM-yyyy)
"#formatDateTime('03-15-2019','yyyy-MM-dd')" ==> OK
Date and time functions provided by azure logic app cannot recognize the timestamp in dd-MM-yyyy format.
After my research, there is no existing function that can directly solve this problem, but you can use substring and concat to deal with this problem.
The workflow of the logic app looks like this:
The expression of the formatDataTime:
formatDateTime(concat(substring(<your-date-string>,6,4),'-',substring(<your-date-string>,3,2),'-',substring(<your-date-string>,0,2)),'yyyy-MM-dd')

Kibana time is not showing in proper format

Kibana is not showing proper timing here i have time like
2020-11-13T18:59:59.999Z
but it is appering like this in Kibana dashboard screenshot attached for further details
Nov 13, 2020 # 00:00:00.00
I am not sure what the question really is:
a) The displayed date format yyyy-MM-dd HH:mm:ss vs. MMM dd, yyyy # HH:mm:ss.SS
b) The time difference 18:59:59 vs. 00:00:00
If a) is the question in Kibana you can select the displayed date format in Stack Managament > Kibana Advanced Setting > Date format
If b) ist the question be aware of the timezone: Elasticsearch stores all timestamps in UTC. You have to specifiy the timezone of your data while storing in Elasticsearch (e.g. Logstash). Kibana shows timestamps based on the specified (user) timezone in Stack Managament > Kibana Advanced Setting > Timezone for date formatting.
See also here: https://discuss.elastic.co/t/kibana-timezone/29270 and here: https://discuss.elastic.co/t/timezone-problem-in-elasticsearch-and-logstash/180163
Check the date format set for the map of the field.
https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html

How to get current date in pega, YY-mm-dd format

I want to get current system date in pega (Year-Month-Date)
YYYY-mm-dd
format.
Using
#(Pega-RULES:DateTime).getCurrentDateStamp()
can get current system date in YYYY-mm-dd(Year-Month-Date) format.
The below, assigned to a Text property, gives date in format yyyyMMdd:
#(Pega-RULES:DateTime).getCurrentDateStamp()
Adjusting solution given here as below, would give the desired format yyyy-MM-dd:
#FormatDateTime(#CurrentDateTime(),"yyyy-MM-dd","America/NewYork","en_US")
Tested on Pega Personal Edition 8.6.0 using Operator with Default locale "en_US" and Time zone America/New_York.
Use this function
#FormatDateTime(#CurrentDateTime(),"MM/dd/yyyy","America/NewYork","en_US")

How to convert a local datetime to UTC with moment.js

I've found a couple of existing StackoverFlow questions on this but nothing very definite.
I have a local datetime. I want this in UTC. my local datetime does not have a 'Z' at the end or any offset information.
I first tried:
moment(mylocaldatetime).toISOString() #works fine because this method always returns time in UTC
But for consistency with other code I didn't want to use to ISOString() so I did this:
moment(mylocaldatetime).utc().format()
This seems to work fine. If the browser running this code is in UTC + 1 I get a datetime one hour less than mylocaldatetime (with an offset string if I specify that in the format). I.e. it has treated mylocaldatetime as a local time, taken account of my current time zone, and given me my local time as UTC.
However. This appears to contradict the moment.js docs which are pretty clear that:
If you want to parse or display a moment in UTC, you can use moment.utc() instead of moment(). - Notice the 'parse'.
and
Moment normally interprets input times as local times (or UTC times if moment.utc() is used).
If these doc comments were true this line:
moment(mylocaldatetime).utc().format()
should treat mylocaldatetime as if it were utc and then output this datetime in utc - no difference. No conversion. But that is not what I get.
Maybe what this line moment(mylocaldatetime).utc().format() is saying is:
create a moment object in local mode with mylocaldatetime. Then put the moment object into utc mode. So now when we format for display we output as utc. IF this is the case I think the docs could be made clearer.

Resources