Why
moment().utc("14:30", "HH:mm").format()
gives me
2019-06-07T00:56:14Z - my local time
instead of
2019-06-07T14:30:14Z
Thank you in advance for help.
Use the moment without () like this moment.utc("14:30", "HH:mm").format()
Related
I am using moment().valueOf() to get unix timestamp and to get the normal time from unix time i'm using moment.unix(unix_time).format('LLL') when the unix value is 1606985226404 getting the anser as May 2, 52893 6:36 AM which is incorrect. What is the issue with this?
According to the documentation of Moment.JS, moment() works with milliseconds.
So:
const unix_time = moment().valueOf(); // return epoc in milliseconds
const now = moment.unix(unix_time / 1000).format('LLL').
That's the trick.
I want to calculate 24 hours - current time so I did like this with moment.js
moment('24:00:00').subtract(now, 'HH:mm:ss').format("HH:mm:ss")
but I recive
Invalid date
Help me
I resolved it like this
moment('24:00:00', 'HH:mm:ss')
.subtract(moment().format("HH"), 'hours')
.subtract(moment().format("mm"), 'minutes')
.subtract(moment().format("ss"), 'seconds')
.format("HH:mm:ss")
Like in a similar query on this forum I need, but I need it to work in Impala:
In a workaround my colleague and myself attempted the following:
-- combine start date and time into a datetime
-- impala can't handle am/pm so need to look for pm indicator and add 12 hours
-- and then subtract 12 hours if it's 12:xx am or pm
================
t1.appt_time,
hours_add(
to_timestamp(concat(to_date(t1.appt_date),' ',t1.appt_time),'yyyy-MM-dd H:mm'),
12*decode(lower(strright(t1.appt_time,2)),"pm",1,0) -
12*decode(strleft(t1.appt_time,2),'12',1,0)
) as appt_datetime,
t1. ...
=========
Has anybody an easier and more elegant approach ?
Your workaround is valid, Impala does currently support AM/PM formatting for dates. There are a few open issues related
https://issues.apache.org/jira/browse/IMPALA-3381
https://issues.apache.org/jira/browse/IMPALA-5237
https://issues.apache.org/jira/browse/IMPALA-2262
I have a data which have the difference between the start and end time of an event. Now I want to add the difference. the problem is the difference time is in format
difference_time
_______________
00:10:00
00:30:12
01:09:09
00:09:03
01:09:30
01:09:03
00:09:08
01:00:09
09:00:01
But if I do sum(df$difference_time) it throws the error that invalid type of arguement.
I want the result to be something like below format:
51975 seconds.
Any help is appreciated
UPDATE:
I tried period_to_seconds(hms(df$difference_time)) and it works fine
period_to_seconds(hms(df$difference_time))
did the trick.
I am using Splunk 6.2.X along with Django bindings to create a Splunk app.
To get access to the earliest/latest dates from the timerange picker, am using the following in my JS.
mysearchbar.timerange.val()
Am getting back a map where the values are in epoch format:
Object {earliest_time: 1440122400, latest_time: 1440124200}
When I convert them using moment using the following, I get different datetime than expected:
> moment.unix('1440122400').utc().toString()
"Fri Aug 21 2015 02:00:00 GMT+0000"
However, the time does not correspond to the values that have been selected on the time range picker i.e. 08/20/2015 22:00:00.000
Am not sure what the difference is getting caused by? Am sure tht the timezone is not the factor as the time difference is erratically not equivalent to derive using simple timezone add/subtract.
I was wondering if this behaviour can be explained as to how to get the Splunk epoch datetime to UTC would be helpful.
I was able to get rid of the timezone issue by performing the following:
Setting the timezone of the Splunk engine to UTC in props.conf as follows:
TZ = GMT
Setting up the CentOS (the server hosting Splunk) to UTC
Hope this helps anyone else who stumbles upon similar issues.
Thanks.