1. Computing

ActionScripting Basics: Basic Date Functions

By

Now, things start to get a little jumbled. I’ll give you the full code first, and then break it down:

stop() ;
today = new Date() ;
dateTextField = ((today.getMonth() + 1) + "/" + today.getDate() + "/" + today.getFullYear()) ;
_root.textdisplay.text="Today's date: "+dateTextField;

Got it? No? That’s okay; let’s tackle it bit-by-bit, starting with the dateTextField = ((today.getMonth() + 1) + "/" + today.getDate() + "/" +
today.getFullYear()) ;
line.

dateTextField is a variable that I’ve made up to encompass the value returned by the date functions. Basically all of these functions strung together will create a value, represented by that single word. dateTextField=today’s date, essentially.

getMonth checks the system date and retrieves the value of the current month; getDate checks the system date and retrieves the value of the current day as an integer; getFullYear checks the system date and retrieves the value of the current year in four-digit format.

©2014 About.com. All rights reserved.