<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>散人笔记 &#187; replace</title>
	<atom:link href="http://www.uideas.cn/post/tag/replace/feed" rel="self" type="application/rss+xml" />
	<link>http://www.uideas.cn</link>
	<description>生活来源于创意,所以我懂生活</description>
	<lastBuildDate>Sun, 22 Aug 2010 07:17:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>js日期判断和获取当前日期</title>
		<link>http://www.uideas.cn/post/233.html</link>
		<comments>http://www.uideas.cn/post/233.html#comments</comments>
		<pubDate>Wed, 10 Mar 2010 10:14:21 +0000</pubDate>
		<dc:creator>kos</dc:creator>
				<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[getDate]]></category>
		<category><![CDATA[getYear]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[当前日期]]></category>
		<category><![CDATA[日期判断]]></category>

		<guid isPermaLink="false">http://www.uideas.cn/?p=233</guid>
		<description><![CDATA[　　最近忙于写一个好用点的日历的js，其中遇到了很多问题，由于小弟技术不精，所以在不断的总结，其中发现了很多有趣的东西，下面这个例子就有几点很有意思，1:获取当前的年份，如果是单纯的用new Date().getYear();有用功获取的话，火狐里面只有三位数，而ie里面是正常的;2:月份获取也得new Date().getMonth() +1;3:这个问题是以前想不明白的，结果在网上找到了解决办法，比较两个日期的天数，得先计算成毫秒。]]></description>
			<content:encoded><![CDATA[<p>　　最近忙于写一个好用点的日历的js，其中遇到了很多问题，由于小弟技术不精，所以在不断的总结，其中发现了很多有趣的东西，下面这个例子就有几点很有意思，1:获取当前的年份，如果是单纯的用new Date().getYear();有用功获取的话，火狐里面只有三位数，而ie里面是正常的;2:月份获取也得new Date().getMonth() +1;3:这个问题是以前想不明白的，结果在网上找到了解决办法，比较两个日期的天数，得先计算成毫秒。<br />
看下面的例子：</p>
<form enctype="application/x-www-form-urlencoded" method="get"><code></p>
<div class="Nodiv">
<div class="Notitle">CODE</div>
<div class="Nocontent"><textarea class="textarea" cols="20" rows="8">&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"&gt; &lt;title&gt;无标题文档&lt;/title&gt; &lt;script language="javascript" type="text/javascript"&gt;  function getCurrentYear(){ 	var year = new Date().getYear(); 	if(year &lt; 1900) year += 1900; 	return year; 	}  function getCurrentMonth(){ 	return new Date().getMonth() + 1; 	} function getCurrentDay(){ 	return new Date().getDate(); 	} function cc(enday){ 	var minutes = 1000 * 60; 	var hours = minutes * 60; 	var days = hours * 24; 	var years = days * 365; 	if(enday == ""){ 		alert("请输入结束日期"); 		} 	else{ 		var today = getCurrentYear()+"-"+getCurrentMonth()+"-"+getCurrentDay(); 		var startDate = new Date(today.replace(/-/g, "/")).getTime(); 		var endDate = new Date(enday.replace(/-/g, "/")).getTime(); 		var val = (startDate-endDate)/days; 		if(val == 0){ 			alert("嘿嘿,你选的是今天"); 			} 		else if(val &gt; 0){ 			alert("今天离"+enday+"已过了"+(startDate-endDate)/days+"天"); 			} 		else{ 			alert("今天到"+enday+"还有"+(endDate-startDate)/days+"天"); 			} 		} 	} &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="text" name="textfield" onBlur="cc(this.value)"&gt; &lt;/body&gt; &lt;/html&gt; </textarea></div>
<div class="Nobutton">
<input onclick="RunCode(this)" type="button" value="运行代码" />
<input onclick="CopyCode(this)" type="button" value="复制代码" />
<input onclick="SaveCode(this)" type="button" value="保存代码" />
<span class="Nots">[Ctrl+A 全部选择 提示：你可先修改部分代码，再按运行]</span></div>
</div>
<p></code></form>
]]></content:encoded>
			<wfw:commentRss>http://www.uideas.cn/post/233.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
