Example Name: HelloUser.asr
Language: ServerSide ActionScript
Version: 1.0.0
Code:
function getTime() {
var d = new Date();
// Format the time with leading zeroes for the seconds and minutes
var seconds = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds();
var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
// Format the hours with a 12-hour clock and AM/PM
var hours = d.getHours();
var am_pm = hours > 12 ? " PM" : " AM";
hours = hours > 12 ? hours-12 : hours;
// Return the time in hh:mm:ss AM/PM format
return hours + ":" + minutes + ":" + seconds + am_pm;
}
function sayHello(username){
return "Hello " + username + ". It is " + getTime();
}
Download code text
Download chapter example files