Hello,
New to BTT. I've looked over the documentation, and I can't seem to find what I'm after. I created a script to get the current UTC time and I want to paste that variable using a keyboard shortcut. Is that possible? I also explored creating a dynamic variable in hopes I could tackle it that way, but no dice.
Run Real JavaScript
// function to convert local time to UTC
async function getUTCTime() {
const localTime = new Date(); // get the local time
const utcTime = localTime.toISOString(); // convert the local time to UTC
const formattedUTCTime = utcTime
.replace(/:/g, '-'); // replace ':' with '-' for filename compatibility
returnVariableValue(formattedUTCTime);
}
I'm not really sure how I would paste the results of the script with a keyboard shortcut with this approach. Any guidance would be appreciated.
Dynamic Variable
Dynamic Variable name:
dynamic_utc
// function to convert local time to UTC
getUTCTime()
const localTime = new Date(); // get the local time
const utcTime = localTime.toISOString(); // convert the local time to UTC
const formattedUTCTime = utcTime
.replace(/:/g, '-'); // replace ':' with '-' for filename compatibility
returnVariableValue(formattedUTCTime)
I tested this script in the BTT editor and it returns the current UTC time. However, I can see where the variable shows up anywhere for use. What am I missing in this approach?
As a side question, what is the difference between returnToBTT and returnVariableValue? What do I use where?