View Full Version : how to retrive todays date in Flash
Can someone help me to retrive todays date in flash automatically...
i would be really grateful..
thanks
Jesse
06-20-2001, 10:57 AM
You can search the forums for heaps of code examples. One stright from Macromedia's AS Dictionary (Fromt he Flash Help Menu):
myDate = new Date();
dateTextField = (mydate.getMonth() + "/" + myDate.getDate() + "/" + mydate.getFullYear());
Returns the date in mm/dd/yyyy form.
BiggieD
06-26-2001, 02:33 PM
How do you add zeros on the ends of minutes and hours if there's only one digit?...i've seen this code like fifty times, but it never worked for me....?
Jesse
07-07-2001, 12:52 PM
well I've not seen any before so I made my onw:
// Zero filler by Jesse, http://www.actionscripts.org
function zeroFill (string, reqLength) {
var tooBig = string.length>=reqLength;
if (!tooBig) {
var dif = reqLength-string.length;
for (var j = 0; j<dif; j++) {
string = "0"+string;
}
}
return string;
}
trace (zeroFill("123",4));
isleshocky77
07-28-2001, 10:28 PM
I made a time thing but I had the same problem w/ the zeros. How do I use your code w/ mine.
code:
----------------------------
//Variables
myTime = new Date();
hour = myTime.getHours();
minutes = myTime.getMinutes();
seconds = myTime.getSeconds();
milliseconds = myTime.getMilliseconds();
//------------------------------
// Sends Time to textbox
//------------------------------
timeTextField = hour+":"+minutes+":"+seconds;
//------------------------------
-----------------------------
Jesse
07-29-2001, 03:14 AM
// Zero Fill Time Code
// by Jesse Stratford, http://www.actionscripts.org
// Set time vars
myTime = new Date();
hours = myTime.getHours();
minutes = myTime.getMinutes();
seconds = myTime.getSeconds();
milliseconds = myTime.getMilliseconds();
// Zero filler by Jesse, http://www.actionscripts.org
function zeroFill (string, reqLength) {
var tooBig = length(string)>=reqLength;
if (!tooBig) {
var dif = reqLength-length(string);
for (var j = 0; j<dif; j++) {
string = "0"+string;
}
}
return string;
}
hours = zeroFill(hours, 2);
minutes = zeroFill(minutes, 2);
seconds = zeroFill(seconds, 2);
milliseconds = zeroFill(milliseconds, 3);
// Set text field var
timeTextField = hour+":"+minutes+":"+seconds;
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.