If this tutorial is not what you were looking for, you still have any questions, suggestions or concerns - feel free to let us know. Please help us to serve you better!

Your Name

Your Email

Your Message (required)


Current time and date in Flash

Q: How can I make my Flash site display current time and date?

A: You can do it with the help of the Date() class available in Action Script. This class has all the necessary methods to retrieve full information about the current time. Before using these methods you need to create a date “object” in the class, this is because the methods are not static and they can only be applied to a single object. To create a Date object please, use the following syntax:

var current_time = new Date();

After that you can use different methods for this object getDate(), getDay(), getFullYear(), getHours(), getMilliseconds(), getMonth() and so on). Use Flash Help documentation to learn more about the Date() class and its methods.
For example:


Note: You can retrieve both your operating system time and universal time – UTC (known before as GMT Greenwich mean time). To display UTC time you should use the methods that have “UTC” in their names (getUTCDate(), getUTCDay(), getUTCFullYear(), getUTCHours(), getUTCMilliseconds(), getUTCMonth() and so on)

See also:

How to set up the current time and date demo movie

Here’s the code used in the demo movie:

var today = new Date();
var minutes = today.getMinutes();
var hours = today.getHours();
var dat = today.getDate();
var month = today.getMonth()+1;
var year = today.getFullYear();
var dayN = today.getDay();
switch (dayN) {
case 0 :
day = "Sunday";
case 1 :
day = "Monday";
case 2 :
day = "Tuesday";
case 3 :
day = "Wednesday";
case 4 :
day = "Thursday";
case 5 :
day = "Friday";
case 6 :
day = "Saturday";
if (hours>12) {
c_time = (hours-12);
AM_PM = "PM";
if (hours==12){
c_time = 12;
AM_PM = "PM";
if (hours<12){
c_time = hours;
AM_PM = "AM";
if (hours==0){
c_time = 12;
AM_PM = "AM";
if (minutes<10) {
is_zero_min = "0";
} else {
is_zero_min = "";
if (dat<10) {
is_zero_dat = "0";
} else {
is_zero_dat = "";
if (month<10) {
is_zero_mon = "0";
} else {
is_zero_mon = "";
output = c_time+":"+is_zero_min+minutes+" "+AM_PM+" "+day+" "+is_zero_dat+dat+"."+is_zero_mon+month+"."+year;

Current time and date in Flash, 2.7 out of 51 based on 3 ratings