Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

<< Prev 5 | Next 5

date

function myDate () {
        now = new Date(year, month, date, hour, min, sec, ms);
        weekday = new Array("Sunday", "Monday", "Tuesday", "Wendnesday", "Thursday", "Friday", "Saturday");
        month = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "Octobert", "November", "December");
        diasemana = weekday[now.getDay()];
        mes = month[now.getMonth()];
        diadelmes = now.getDate();
        modifier = new CreateArray(31);
        var modifier = new String("thstndrdthththththththththththththththththstndrdthththththththst");
        var loop = 0;
        do {
                modifier[loop] = modifier.substring(loop*2, 2+(loop*2));
                loop = loop+1;
        } while (loop<32);
        mySuffix = modifier[now.getDate()];
        ano = now.getFullYear();
        fecha_entera = weekday[now.getDay()]+"  "+month[now.getMonth()]+" "+now.getDate()+mySuffix+" "+now.getFullYear();
        return fecha_entera;
}
myDate();

Posted by: LordAlex Leon | website http://www.lordalex.com
Date
//Here I made an clock:
movieclip.prototype.analoguhr = function () {
        Zeit = new Date();
        sekunden=Zeit.getSeconds();
        minuten=Zeit.getMinutes();
        stunden=Zeit.getHours();
        sek._rotation = sekunden*6;
        min._rotation = minuten*6;
        std._rotation = stunden*30+minuten*0.5
}

movieclip.prototype.datum = function() {
        zeit=new Date();
        tag=zeit.getDate();
        monat=zeit.getMonth()+1;
        jahr=zeit.getFullYear();
        if (tag < 10) { tag = "0"+tag;}
        if (monat < 10){ monat = "0" + monat;}
        zeitfeld= (tag+"."+monat+"."+jahr);
}
datum()

//Have fun with it.

Posted by: kazz | website http://www.bbidd.co.jp
Date and calendar help
mydate=new Date()
months=['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
currentday=mydate.getDate()
currentmonth=months[mydate.getMonth()]
currentyear=mydate.getFullYear()
today=currentmonth+currentday+currentyear
then to check it use:
if(_root.today == "February22001"){
        //today is february 2nd 20001
}

Posted by: No name | website http://
Date Extension Class
/*
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Title : 		XDate Class
Author : 		P.J. Onori
URL : 			http://www.somerandomdude.net/flash_xdate.html

Description :	Extension of Macromedia's Date class for Flash MX 2004+. Various methods to get more detailed
date information. This class was designed for calendar-based applications and provides many useful
methods to pull out all the data needed to do so.

Created : 		7/22/05
Modified : 		9/17/05

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/

class pjonori.util.XDate extends Date {
        
        private var monthDays:Number
        private var monthWeeks:Number;
        private var weekArray:Array;
        
        /*
        Day names in various langauges (sorry, no Arabic or Eastern langauges at this point).
        EN - English
        SP - Spanish
        FR - French
        GR - German
        IT - Italian
        */
        
        private var dayNameEN:Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
        private var dayNameSP:Array = new Array("El Domingo", "El Lunes", "El Martes", "El Miércoles", "El Jueves", "El Viernes", "El Sábado");
        private var dayNameFR:Array = new Array("Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi");
        private var dayNameGR:Array = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag");
        private var dayNameIT:Array = new Array("Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato");
        
        /*
        Month names in various langauges.
        EN - English
        SP - Spanish
        FR - French
        GR - German
        IT - Italian
        */
        
        private var monthNameEN:Array = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
        private var monthNameSP:Array = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
        private var monthNameFR:Array = new Array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
        private var monthNameGR:Array = new Array("Januar", "Februar", "Marschiert", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
        private var monthNameIT:Array = new Array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");
        
        function XDate(year:Number,month:Number,date:Number,hour:Number,min:Number,sec:Number,ms:Number) {
                
                setYear(year);
                setMonth(month);
                setDate(date);
                this.setDaysInMonth();
                this.setWeeksInMonth();
                
                /*
                This class does not handle any time units lower than days at this point.
                setHours(hour);
                setMinutes(min);
                setSeconds(sec);
                setMilliseconds(ms);
                */
        }
        
        /*
        * Function:	getDayOfWeek
        * Summary:		Get the day of the week (0 = Sunday, 6 = Saturday),
                                                             *              based on the day of the month.
        * Parameters:	day – a day of the object's month
        * Return:      Number (0-6) indicating the day of week
        */
        public function getDayOfWeek(day:Number):Number	{
                var dayBackup:Number = this.getDate();		//create backup of object's actual given date
                this.setDate(day);							//set the object's day from the passed value
                var dayOfWeek:Number = super.getDay();
                this.setDate(dayBackup);					//return object's day to original value
                
                return dayOfWeek;
        }
        
        /*
        * Function:	isSunday
        * Summary:		Function to inidicate whether a day is Sunday
        * Parameters:	day – a day of the object's month
        * Return:      Boolean indicating if the day is Sunday or not
        */
        public function isSunday(day:Number):Boolean	{
                if(this.getDayOfWeek(day)==0)	{
                        return true;
                }
                return false;
        }
        
        /*
        * Function:	isMonday
        * Summary:		Read isSunday's comments for summary & details
        */
        public function isMonday(day:Number):Boolean	{
                if(this.getDayOfWeek(day)==1)	{
                        return true;
                }
                return false;
        }
        
        /*
        * Function:	isTuesday
        * Summary:		Read isSunday's comments for summary & details
        */
        public function isTuesday(day:Number):Boolean	{
                if(this.getDayOfWeek(day)==2)	{
                        return true;
                }
                return false;
        }
        
        /*
        * Function:	isWednesday
        * Summary:		Read isSunday's comments for summary & details
        */
        public function isWednesday(day:Number):Boolean	{
                if(this.getDayOfWeek(day)==3)	{
                        return true;
                }
                return false;
        }
        
        /*
        * Function:	isThursday
        * Summary:		Read isSunday's comments for summary & details
        */
        public function isThursday(day:Number):Boolean	{
                if(this.getDayOfWeek(day)==4)	{
                        return true;
                }
                return false;
        }
        
        /*
        * Function:	isFriday
        * Summary:		Read isSunday's comments for summary & details
        */
        public function isFriday(day:Number):Boolean	{
                if(this.getDayOfWeek(day)==5)	{
                        return true;
                }
                return false;
        }
        
        /*
        * Function:	isSaturday
        * Summary:		Read isSunday's comments for summary & details
        */
        public function isSaturday(day:Number):Boolean	{
                if(this.getDayOfWeek(day)==6)	{
                        return true;
                }
                return false;
        }
        
        /* Function:	isWeekend
        * Summary:		Checks to see if the day is part of the weekend
        * Parameters:	day – a day of the object's month
        * Return:      Boolean indicating if the day is during the weekend
        */
        public function isWeekend(day:Number):Boolean	{
                if(this.getDayOfWeek(day)==6||this.getDayOfWeek(day)==0)	{
                        return true;
                }
                return false;
        }
        
        /*
        * Function:	setDaysInMonth
        * Summary:		Finds the total amount of days in the object's month
        * 				and sets 'daysInMonth' with the value
        */
        function setDaysInMonth():Void {
                var tempDate = new Date(this.getYear(), this.getMonth()+1, 0);
                this.monthDays = tempDate.getDate();
                delete tempDate;
        }
        
        /*
        * Function:	daysInMonth
        * Summary:		Returns the total number of days in the object's month
        * Return:      The total number of days in the month
        */
        function get daysInMonth():Number {
                return this.monthDays;
        }
        
        /*
        * Function:	getDaysLeftInMonth
        * Summary:		Returns the total number of days left in the object's month
        * Return:      The total number of days left in the month
        */
        function getDaysLeftInMonth():Number	{
                return this.daysInMonth-super.getDate();
        }
        
        /*
        * Function:	getDaysInYear
        * Summary:		Finds the total amount of days in the object's year
        * 				primarily useful to detect leap years
        * Return:      The total number of days in the year
        */
        function get daysInYear():Number {
                var daysInYear:Number=0;
                var i:Number=0;
                var year:Number=13;
                while(++i<year)	{
                        var tempDate = new Date(this.getYear(), i, 0);
                        daysInYear+= tempDate.getDate();
                }
                return daysInYear;
        }
        
        /*
        * Function:	getMonthStartDate
        * Summary:		Finds the day (i.e Monday, Tuesday, etc.)
        * 				that the first day of the object's month lands on
        */
        function monthStartDate():Number {
                var dayBackup:Number = this.getDate();
                this.setDate(1);
                var day:Number = super.getDay();
                this.setDate(dayBackup);
                return day;
        }
        
        /*
        * Function:	getMonthEndDate
        * Summary:		Finds the day (i.e Monday, Tuesday, etc.)
        * 				that the last day of the object's month lands on
        */
        function monthEndDate():Number {
                var dayBackup:Number = this.getDate();
                var lastDay:Number = this.daysInMonth;
                this.setDate(lastDay);
                var day:Number = super.getDay();
                this.setDate(dayBackup);
                return day;
        }
        
        /*
        * Function:	setWeeksInMonth
        * Summary:		Sets the total number of weeks in the object's month
        */
        function setWeeksInMonth():Void	{
                monthWeeks=0;
                var days:Number = this.daysInMonth;
                var i:Number = 0;
                while(++i<days+1)	{
                        if(this.isSaturday(i)==true&&monthWeeks==0)	{
                                monthWeeks+=1;
                        }
                        else if(this.isSunday(i)==true&&i!=1)	{
                                monthWeeks+=1;
                        }
                }
        }
        
        /*
        * Function:	getWeeksInMonth
        * Summary:		Gets the total number of weeks in the object's month
        */
        function get weeksInMonth():Number	{
                return monthWeeks;
        }
        
        /*
        * Function:	getDaysInWeeks
        * Summary:		Returns an array with the total number of days
        * 				for each week in the object's month
        */
        function get daysInWeeks():Array	{
                var day=1;
                var weekCount:Number=0;
                var daysCounted:Number=0;
                var weekArray:Array = new Array();
                var days = this.daysInMonth;
                var i=-1;
                while(++i<days)	{
                        this.setDate(i+1);
                        if(super.getDay()==6 && weekCount==0)	{
                                weekCount+=1
                                daysCounted = i;
                                weekArray.push(daysCounted+1);
                                
                        }
                        else if(super.getDay()==0&&i<days-7&&i!=0)	{
                                weekCount+=1
                                weekArray.push(7);
                                daysCounted+=7;
                        }
                        
                }
                weekArray.push((days-1)-(daysCounted+1)+1);
                return weekArray;
        }
        
        /*
        * Function:	getDaysInWeek
        * Summary:		Returns the total amount of days in a specified week
        * 				of the object's month
        */
        function daysInWeek(week:Number):Number	{
                var weeks:Array = this.daysInWeeks();
                if(week>weeks.length||week<0)	{
                        return null;
                }
                return weeks[week];
        }
        
        /*
        * Function:	getDay
        * Summary:		Finds the day for any date specified
        */
        function getDay(month, year, day):Number	{
                return (new Date(year, month, day).getDay());
        }
        
        /*
        * Function:	getDayName
        * Summary:		Returns the name of the day specified in the language specified
        * Parametets:	Number of days (starting w/ 0), Language of name (EN = english, FR = french, etc.)
        */
        function getDayName(day:Number, lang:String):String	{
                if(day>=0||day<=6)	{
                        switch(lang)	{
                                case "EN":
                                return dayNameEN[day];
                                break;
                                case "SP":
                                return dayNameSP[day];
                                break;
                                case "FR":
                                return dayNameFR[day];
                                break;
                                case "GR":
                                return dayNameGR[day];
                                break;
                                case "IT":
                                return dayNameIT[day];
                                break;
                                default :
                                return dayNameEN[day];
                                break;
                        }
                }
                else {
                        return null
                }
        }
        
        /*
        * Function:	getMonthName
        * Summary:		Returns the name of the month specified in the language specified
        * Parametets:	Number of month (starting w/ 0), Language of name (EN = english, FR = french, etc.)
        */
        function getMonthName(month:Number, lang:String):String {
                if(month>=0||month<=6)	{
                        switch(lang)	{
                                case "EN":
                                return monthNameEN[month];
                                break;
                                case "SP":
                                return monthNameSP[month];
                                break;
                                case "FR":
                                return monthNameFR[month];
                                break;
                                case "GR":
                                return monthNameGR[month];
                                break;
                                case "IT":
                                return monthNameIT[month];
                                break;
                                default :
                                return monthNameEN[month];
                                break;
                        }
                }
                else {
                        return null
                }
        }
}

Posted by: P.J. Onori | website http://www.somerandomdude.net
Date Object - Extensions
//===================================================================
// Some extensions to the Date object (useful for calendars)
// by Flashman247
//===================================================================
_root.DayNames = "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(",");
_root.MonthNames = "January,February,March,April,May,June,July,August,September,October,November,December".split(",");

// <string> = Date string (note the trick for 'th' 'st' 'nd' or 'rd' postfix)
Date.prototype.getFullDate = function() {
        var n = this.getDate();
        var tx = _root.DayNames[this.getDay()]+ " " + n;
        tx += ((n=((n%30)%20)*2)<8)? "thstndrd".slice(n,n+2):"th";
        tx += " " + _root.MonthNames[this.getMonth()];
        tx += " " + this.getFullYear();
        return tx;
}

// <days> = Number of days in the current month (deals with leap-years too)
Date.prototype.getDaysInMonth = function() {
        for (var i=28; i<=(this.getMonth()!=1? 31:29); i++) {
                var temp = new Date(this);
                temp.setDate(i);
                if (i==temp.getDate()) { var days=i; }
        }
        return days;
}
// <num> = Starting day of the week (0-6)
Date.prototype.getMonthStartDay = function() {
        var tdate = new Date(this);
        trace ("getMonthStartDay( "+tdate);
        tdate.setDate(1);
        return tdate.getDay();
}
// <daynum> = Get UTC day number from 1st Jan 1970
Date.prototype.getDayNumber = function() {
        return Math.floor(Number(this.valueOf())/(1000*60*60*24));
}
// Set UTC (daynum)
Date.prototype.setDayNumber = function(daynum) {
        var t = new Date(daynum*1000*60*60*24);
        this.setUTCFullYear(t.getFullYear(), t.getMonth(), t.getDate());
}
ASSetPropFlags(Date.prototype, "getDaysInMonth,getMonthStartDay,getDayNumber,setDayNumber", 7);

// move onto the previous calendar day
Date.prototype.previousDay = function() {
        this.setDayNumber(this.getDayNumber()-1);
}
// move onto the next calendar day
Date.prototype.nextDay = function() {
        this.setDayNumber(this.getDayNumber()+1);
}
ASSetPropFlags(Date.prototype, "previousDay,nextDay", 7);
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// DEMO BELOW
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
theDate = new Date();

// demo the new 'getFullDate()' method //
trace ("full date is:"+theDate.getFullDate());

// demo the 'getDaysInMonth()' method //
for (var month=0; month<12; month++) {
        theDate.setMonth(month,1);
        trace (theDate.getDaysInMonth() +" days in "+_root.MonthNames[month]);
}

// demo the 'getDayNumber()' method //
for (var day=0; day<30; day++) {
        theDate.setDate(day);
        trace ("day number:"+theDate.getDayNumber()+" = "+theDate.getFullDate());
}
// demo the 'setDayNumber()' method //
theDate.setDayNumber(12020);

// demo the 'previousDay()' & 'nextDay()' methods //
theDate.previousDay();
for (var i=0; i<10; i++) {
        trace(theDate);
        theDate.nextDay();
}
// END-OF-DEMO //

Posted by: FlashMan247 | website http://www.i-dont-have-a-url.com

<< Prev 5 | Next 5

Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.