Return to Snippet

Revision: 32625
at September 30, 2010 19:32 by online


Initial Code
function getCurrentTime(){
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();
var day:String;
var c_time:Number;
var AM_PM:String;
var is_zero_min:String;
var is_zero_dat:String;
var is_zero_mon:String;
var output:String;

switch (dayN) {
case 0 :
day = "Sun";
break;
case 1 :
day = "Mon";
break;
case 2 :
day = "Tue";
break;
case 3 :
day = "Wed";
break;
case 4 :
day = "Thu";
break;
case 5 :
day = "Fri";
break;
case 6 :
day = "Sat";
break;
}
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;
trace(output);
}

Initial URL

                                

Initial Description

                                

Initial Title
Current Date and Time

Initial Tags
date

Initial Language
ActionScript 3