Syntax for time, date etc functions


#1

Is there, somewhere out there, a page/reference where I can understand the exact syntax used for the various time, date, hour, month, day variables used in Axure? I’m using them in prototypes all the time, but only from stealing working strings from other prototypes I didn’t build, and some of the calculations just defy my comprehension.

For instance (Time) and substrings. (Time.length) returns 18 but when I just do (Time) I’m returned something like HH:MM:SS AM - which to me counts as 11, and so if I want to extract specific bits of (Time) I can only do it by flogging someone else’s work which I don’t really understand, as using simple substring character position counting returns me not what I’m expecting - so clearly there’s something I don’t understand about (Time) and its length and how to work on it. But everyone else seems to know it.

I’ve looked at any number of threads in this forum - and they have a lot of useful tips for how to solve exact problems which people are having - and I’ve looked through the Axure site and nowhere can I find a simple explanation of the syntax for these functions, armed with which I may actually be able to do things I want to do instead of spending hours haunting this place trying to work it out and grinding my teeth in frustration when I can’t understand what’s in front of me. :slight_smile:

I’m not after a solution to the particular problem above as such, I’m after a reference where I can read up and work out what, conceptually, I don’t know. I’m not stupid, I’m just missing some information.

TIA anyone who can help!


Real time display
#2

Hi DavidS,

The closest reference page you will find is our Math, Functions, and Expressions page, linked below:

https://www.axure.com/support/reference/math-functions-and-expressions

as well as the below link, which we reference to in the above article:

While it doesn’t go into specifics about [[Time]] and [[Time.length]], the .length function should give you the length of a string, e.g. 11 from HH:MM:SS AM. I was able to get a result of 11 when using [[Time.length]], but it sounds like you’re getting 18 - is that right? The function output may depend on the OS, the browser, or the language/region of the machine, so I’m thinking this may be why you’re getting different results, but lmk if you want to investigate this further. :slight_smile:


#3

Hi!

I’m guessing that since you are querying the length of the [[Time]] string, you are trying to get the individual portions of that using string functions.

Another way to do it is to use date functions. For instance, if you want to get the current minute, you can say:

[[Now.getMinutes()]]

This won’t come with a leading zero (e.g., when the minute is less than 10) so you can do this

[[ "0".concat( Now.getMinutes() ).slice( -2 ) ]]

which basically prepends a zero to whatever the minute is (e.g., “011” if it’s 4:11, or “05” if it’s 4:05) and then “slices” the last two characters only and uses those

Keep in mind hours in these functions are on a 24 hour clock, so if you wanted 12-hour-clock values:

[[Now.getHours() % 12]]

You can find these functions in the Variable or Function dropdown in the fx box.

Oh! If you get into dates, a common mistake is using Now.getDay() to get the day-of-the-month. That’s Now.getDate(). Now.getDay returns the day-of-the week, where Sunday is 0 and Saturday is 6.


#4

Hi Jane - thanks for replying - that’s interesting, because I clearly get something that’s not 11 - although I can count quite well and that’s how many I should get. I’ve just done it again and I’m getting 17 now, which makes not much sense unless if it’s because it’s not yet 10am and when I tried last time it was after 10. I may try another browser and see what happens, but we’re sort of locked to IE, alas, at least locally. I have a general frustration with not being able to find a reference for all this stuff however, because while this may solve one problem, there’s bound to be another just around the corner somewhere. I can’t be the only one - and I’m guessing, like most people who use Axure in a more advanced way, I’m quite capable of dealing with various forms of syntax, so long as I have a reference to explain them - and this is what I can’t find anywhere!

I found the Mozilla page myself, incidentally, but as you noted, it doesn’t have the particular (Time) function on it.

You see the other person who’s replied - josephxbrick - clearly is into this way deeper than I am, and is using functional methods I could use, if only I knew they were available, and what the syntax was - but if Axure detail the exact capability anywhere, I’ve missed it. I’ll have a good read of the Mozilla page, however.

Cheers


#5

Thanks Joseph - very interesting. Clearly there’s a lot I don’t yet know about Axure and its ability to do this stuff - as I’ve whinged about above / below, I could probably work it out if I had a reference for the syntax.

You’ve done a few things above which I didn’t even know were possible but now do and that’s great and thanks for the tips, but that seems to be the way with this software, and other software generally these days - you have to go to a forum and hope another user can answer your question! I guess that supports the aftermarket for courses, however, which may be part of the Axure business model. Who knows?

Cheers and thanks for the help.


#6

Almost a year later, I realised you’d given me exactly what I needed! Somehow I missed the reply… :open_mouth:

I went looking for something else along similar lines and found your reply. Thanks Jane! (assuming you’re still there, that is…) :wink:


closed #7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.