hi, i need to retrieve date and time, to put them in a separated variable…to work than thim them…
Can some body help me please, step by step…?? i don’t see many examples like this…Gdevelop is great but not so many intuitive for me…best regards…Lestroso
Sorry i did not ask if you needed the numeric values, if you copy and past the JavaScript below into a JavaScript event it will put put the separate values into the scene variables
hour
minutes
day
month
year
if you edit the script you can change them to whatever you like
// Get the current date and time
const now = new Date();
// Break down the time
const hours = now.getHours(); // Get current hour (0-23)
const minutes = now.getMinutes(); // Get current minutes (0-59)
// Break down the date
const day = now.getDate(); // Get current day of the month (1-31)
const month = now.getMonth() + 1; // Get current month (0-11, so we add 1 to make it 1-12)
const year = now.getFullYear(); // Get current year
// Pass the values to GDevelop variables
runtimeScene.getVariables().get(“hour”).setNumber(hours);
runtimeScene.getVariables().get(“minutes”).setNumber(minutes);
runtimeScene.getVariables().get(“day”).setNumber(day);
runtimeScene.getVariables().get(“month”).setNumber(month);
runtimeScene.getVariables().get(“year”).setNumber(year);
thanks a lot for your precious code and answer… this work fine for me …but i have had to create 2 variables to set your demo code…thanks a lot again…Lestroso