Speaking Correct Time Format


1) Give a description of the problem
I am working on two pistons that will be triggered by Ask Alexa. One updates a global variable of type Time (time only) when a user tells Alexa “The dog was fed.” The other will read back the time the dog was fed when someone asks Alexa “What time was the dog fed?” For some reason, I cannot get Lannouncer to leave off the time zone. The time is spoken correctly (e.g., 2:21 PM) but MST (mountain standard time) is also spoken. I think I’m formatting the variable correctly but maybe not.

2) What is the expected behavior?
I only want to hear the hour, minute and AM or PM

3) What is happening/not happening?
The time zone is being announced instead of just the time.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach any logs (From ST IDE and by turning logging level to Full)

If a solution is found for your question then please mark the post as the solution.

Convert UTC / Epoch Time to Human Time

This is the output I get.

(expression) formatDateTime($now, ‘h:mm a’) »»» (string) 2:35 PM


Interesting. I used the same format you used:

The variable itself just shows this: time @timeDogWasFedTime 3:28:00 PM

But the log shows that MST is being used when the string is formulated. I’m stumped.

12/28/2017, 3:28:39 PM +258ms
+1ms ╔Received event [Home].test = 1514500119258 with a delay of 0ms
+104ms ║RunTime Analysis CS > 24ms > PS > 55ms > PE > 25ms > CE
+106ms ║Runtime (38183 bytes) successfully initialized in 55ms (v0.2.100.20171211) (103ms)
+107ms ║╔Execution stage started
+112ms ║║Cancelling statement #1’s schedules…
+123ms ║║Executed virtual command setVariable (0ms)
+127ms ║║Cancelling statement #4’s schedules…
+134ms ║║Calculating (string) Okay, I’ve noted that you fed the dog at + (string) 3:28:00 PM MST >> (string) Okay, I’ve noted that you fed the dog at 3:28:00 PM MST
+136ms ║║Calculating (string) Okay, I’ve noted that you fed the dog at 3:28:00 PM MST + (string) . >> (string) Okay, I’ve noted that you fed the dog at 3:28:00 PM MST.
+293ms ║║Executed physical command [null].speak([Okay, I’ve noted that you fed the dog at 3:28:00 PM MST.]) (152ms)
+294ms ║║Executed [LANnoucer].speak (154ms)
+296ms ║╚Execution stage complete. (189ms)
+297ms ╚Event processed successfully (297ms)


Interesting indeed! No speakers at my current location for testing.


It worked correctly on my test with a vlcthing. I don’t have a Lanouncer at the moment.



Thanks for your help trying to troubleshoot this one. Maybe it’s some obscure WC setting somewhere. I ended up doing the following to extract just the time. This and the companion piston (When was the dog last fed?) are both working now.



Was having this issue as well. Solved it by using Dynamic instead of Time in the Variable definition.


When I use $time in a local expression like this:


It speaks exactly as shown in the grey box.

On my pistons where I do not want to hear the AM/PM, I use this:


(myMinutes is a string, and the "O "$minute is the letter O)

This returns one of 3 phrase endings:

  • The sun is setting at five o’clock
  • The sun is setting at five oh five
  • The sun is setting at five ten

This takes a few lines of code, but the voice response is the most natural I have ever heard from a computer.

Ooops, I just noticed the date on this thread…


Sometimes its a great idea to update an old thread. “Old” issues for some are “New” issues for many. What you posted will not only help me but others as well.