Forum Discussion
Javascript variable / Current Date
Hello, Can someone give me the javascript to display the current date by using a variable? It is similar to the below javascript but I need it to display the date numerically like "06/20/2023"
var options = {weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }; var date = new Date().toLocaleTimeString('en-us', options); var player = GetPlayer(); player.SetVar("SystemDate",date);
- KaitlynneBeck-0Community Member
This is super helpful and I'm looking at adding something similar. However, is it possible to add today's date but have it contingent on the time? I'm working to set the TRADE date for the stock market, and because the stock market closes at 4PM EST, I need the date to stay as the current date or change to the next business day if a trade happens after 4PM EST. Is this possible??
- DanielManitskyCommunity Member
Just a note- Make sure when creating your variable for todaysDate that it is a TEXT variable and not a number variable.
- K-HCommunity Member
Is it possible to set the month as a text variable. I'm trying to create a certificate that caters to different regions where they may put the month ahead of the day. So I thought this might be a way to counter that and avoid confusion.