0

I need to be able to get the current date, it doesn't really matter what format it is. Is there a function, or perhaps an API i can use?

2 Answers2

1

You can get the current date a number of ways in GML. The easiest of which is probably using the variables current_second, current_minute, current_hour, current_day, current_weekday, current_month, current_year

Here's an example that draws the day, month, and year.

draw_text(32, 32, "Today is " + string(current_day) + "/" + string (current_month) + "/" + string(current_year) +".");

You can change the timezone using date_set_timezone(timezone); The available timezones are timezone_utc and timezone_local.

Another way to get the date is using date_current_datetime();

myhour = date_get_hour(date_current_datetime());
myday = date_get_day(date_current_datetime());
Tanner Helton
  • 89
  • 1
  • 1
  • 12
0

It exists some ways to do it. If you only need to show the current datetime you can use this:

show_message("Today is " + string(current_day) + "/" + string (current_month) + "/" + string(current_year) + " - "  + string(current_hour) + ":" + string(current_minute) + "." + string(current_second) +".");

This will return something like: "Today is 3/6/2017 - 23:40:15."

wallium
  • 19
  • 4