Error Screenshot: Image Link
I'm trying to convert the UTC Time Zone i.e the value output received from utcnow() function to Indian Standard Time but this is the error:
Unable to process template language expressions in action 'Compose_2' inputs at line '0' and column '0': 'The template function 'Today' is not defined or not valid.'.
I have tried to convert the UTC Time zone to IST using the following expression:
convertTimeZone(utcNow(),Day(Today()))
convertFromUtc(utcNow(),'Indian Standard Time')
I'm expecting this UTC Time to be converted in Indian Standard Time
Related
Can someone explain why this IF statement is returning false if the current UTC time is 16:21 and the function is to return true if the current UTC time is >=09:00:00 && <=17:00:00
Have tried separate IF statements and extending the time bracket beyond reasonable doubt
Most likely because you're comparing a UTC time object to a string representation of the time. utcTime == string will not evaluate to true since a UTC time object and a string cannot be the same, and the UTC time converted to a string would not take the same format (as you can see when you printed the time.
The solution would be to instead create two UTC time objects with their values set to 09:00:00 and 17:00:00 respectively and comparing the current time to those instead.
= utcNow('HH:mm:ss') >= `09:00:00` && utcNow('HH:mm:ss') < `17:00:00`
Solution to question. Needed to enter time format similar to that of UTC format.
In a Power Automate / MSFlow flow, I receive a string like this:
Saturday, July 31, 2021 1:35 AM | (UTC+01:00) Dublin, Edinburgh, Lisbon, London
I need to convert it to the format Sharepoint expects, i.e. a ISO 8601 for UTC:
YYYY-MM-DDTHH:MM:SS
I painfully built a flow that does most of the work; however, at the thought of having to manually manage the timezone offset my heart finally gave out. It's shocking that in 2021 a product like this cannot parse a datetime like we could do in any language in 1995.
So my question is: what's the easiest way to parse this datetime correctly in PA/Flow...?
I followed the MS reference:
Workflow definition language functions reference: formatDateTime
And the way to go was with "formatDateTime" function:
formatDateTime('<timestamp>', '<format>'?)
But, before that, the timestamp should be reformated in your case.
My approach will be the following:
Let's assume that the input string will be stored in a variable named timestamp_original.
Take the part before "|" character from the timestamp_original. and remove the Day (at the beginning) from the result.
pass the result to the formatDateTime function.
Use the convertTimeZone function to achieve the TimeZone conversion. (but this part is not working as I expected).
So the final result should be obtained by using the next expressions:
convertTimeZone(formatDateTime(first( split( substring(variables('timestamp_original'), add(2, indexOf(variables('timestamp_original'),','))) , '|' ) )), 'Central Europe Standard Time', 'Greenwich Standard Time')
The solution to the point 3, should be extracting the TimeZone from the timestamp_original string:
trim(first(split(last( split(variables('timestamp_original'), '(' ) ), ')')))
And add some logic to test if this TimeZone contains "UTC+" or "UTC-" and add or extract hours from the obtained timestamp.
I think you can do this.
It should be noted that the variable 'timestamp_original' should be initially in the next format (as the OP mentionned):
Saturday, July 31, 2021 1:35 AM | (UTC+01:00) Dublin, Edinburgh, Lisbon, London
So the result will be: (using the convertTimeZone function)
2021-07-30T23:35:00.0000000
And without using the convertTimeZone function:
2021-07-31T01:35:00.0000000
I hope this has helped. Good luck.
I've been using this answer to convert epoch time to DateTime. I have this epoch number:
epoch = 1549626705942
and do:
Time.at(epoch).to_datetime
However, I get this as the result:
#<DateTime: 51075-09-19T08:45:42+02:00 ((20376082j,24342s,0n),+7200s,2299161j)>
I'm using Ruby version 2.5.3p105 and my clock is set to the current year. This epoch value evaluates to today's date (February 2nd, 2019) yet I get a year 51075. Really not sure what's going on.
It's also weird because, when I enter my timestamp at a site like this one I get today's date but here I get the same result as my Ruby code.
Edit: I tried to remove the last 3 numbers of this date and got a correct date. So is it that there are 2 epoch "formats" so to say?
You are passing miliseconds to the Time::at() method. You should pass seconds there. Link to docs is here.
To retrieve Epoch value(in seconds), use Time#to_i
UPD
This will work for you:
Time.at(0, your_epoch_milliseconds, :millisecond)
I want to get the current date and time as example date: 11/10/2014 and time 8:30 am or 6:00 pm and pass it as parameters to my Jmeter test. Can some help me do this.
Use __time function:
${__time(dd/MM/yyyy,)}
${__time(hh:mm a,)}
Since JMeter 3.3, there are two new functions that let you compute a time:
__timeShift
"The timeShift function returns a date in the given format with the specified amount of seconds, minutes, hours, days or months added" and
__RandomDate
"The RandomDate function returns a random date that lies between the given start date and end date values."
Since JMeter 4.0:
dateTimeConvert
Convert a date or time from source to target format
If you're looking to learn jmeter correctly, this book will help you.
it seems to be the java SimpleDateFormat : http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
here are some tests i did around 11:30pm on the 20th of May 2015
${__time(dd-mmm-yyyy HHmmss)} 20-032-2015 233224
${__time(d-MMM-yyyy hhmmss)} 20-May-2015 113224
${__time(dd-m-yyyy hhmmss)} 20-32-2015 113224
${__time(D-M-yyyy hhmmss)} 140-5-2015 113224
${__time(DD-MM-yyyy)} 140-05-2015
JMeter is using java SimpleDateFormat
For UTC with timezone use this
${__time(yyyy-MM-dd'T'hh:mm:ssX)}
Use ${__time(yyyy-MM-dd'T'hh:mm:ss)} to convert time into a particular timeformat.
Here are other formats that you can use:
yyyy/MM/dd HH:mm:ss.SSS
yyyy/MM/dd HH:mm:ss
yyyy-MM-dd HH:mm:ss.SSS
yyyy-MM-dd HH:mm:ss
MM/dd/yy HH:mm:ss
You can use Z character to get milliseconds too.
For example:
yyyy/MM/dd HH:mm:ssZ => 2017-01-25T10:29:00-0700
yyyy/MM/dd HH:mm:ss.SSS'Z' => 2017-01-25T10:28:49.549Z
Most of the time yyyy/MM/dd HH:mm:ss.SSS'Z' is required in some APIs. It is better to know how to convert time into this format.
Actually, for UTC I used Z instead of X, e.g.
${__time(yyyy-MM-dd'T'hh:mm:ssZ)}
which gave me:
2017-09-14T09:24:54-0400
Use this format:
${__time(yyyy-MM-dd'T'hh:mm:ss.SS'Z')}
Which will give you:
2018-01-16T08:32:28.75Z
Should have double quotes surrounding the ${}
String todaysDate = "${__time(yyyy-MM-dd'T'HH:mm:ss.SSS'Z')}";
I am learning programming and I choose Ruby as the first language to learn.
I am parsing an XML where dates are in this form: 1240915075 1224855068
How is this format called? How to use that value in a Date or Time object?
Thank you!
This is UNIX time (sometimes called Epoch time). It measures the number of seconds elapsed since January 1, 1970 (The Unix epoch is the time 00:00:00 UTC on 1 January 1970)
Here's an example converter: http://www.esqsoft.com/javascript_examples/date-to-epoch.htm
A stackoverflow question regarding converting integer time using Ruby: Ruby / Rails: convert int to time OR get time from integer?
use the Time.at function to convert e.g.:
t = Time.at(i)
That's Epoch Time (the first one corresponds to Tue Apr 28 2009 11:37:55 GMT+0100).
You can get a datetime out of it, using Time.at, like this:
Time.at(1240915075)
That is a unix timestamp - the number of seconds since jan 1st 1970.
An example of how to use it in Ruby is here:
t = Time.at(1215163257)
puts t.to_date
>> 2008-07-04