日期检测器-根据系统时钟更改日期
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了日期检测器-根据系统时钟更改日期相关的知识,希望对你有一定的参考价值。
Useful for event dates - looks at the computers clock and tells the user when something will be available (e.g. this friday, tomorrow, etc). In this example I'm just using the day of a month, but you can use any part/the full date if you desire.Help me make this snippet better!
var showNowDate : Boolean; var today_date : Date = new Date(); var thismonth : uint = today_date.getMonth(); var mnth : Array = new Array( 'January','February','March','April','May','June','July','August','September','October','November','December' ); var date_str : String = ( today_date.getDate()+" "+mnth[thismonth]+" "+today_date.getFullYear()); // displays current date in United States date format trace(date_str); // create sample text field var dateTxt : TextField = new TextField(); addChild(dateTxt); handleDate(); function handleDate() { var d = today_date.date; // replace these 'if statements' as needed. if ( d < 17 ) { dateTxt.text = "Coming July 23"; } else if ( d > 17 && d < 22 ) { dateTxt.text = "Coming Friday"; } else if ( d == 22 ) { dateTxt.text = "Coming Tomorrow"; } else { dateTxt.text = "Now!"; } }
以上是关于日期检测器-根据系统时钟更改日期的主要内容,如果未能解决你的问题,请参考以下文章