当月的所有周日 倒计时显示当年剩下的天时分秒 公历转农历

<script type="text/javascript">
var year = new Date().getFullYear();
var month = new Date().getMonth();
var result = [];
for(var i = 1; i <= 31; i++){
    
var weekday = new Date(year, month, i).getDay();
    
if(weekday == 0 || weekday == 6 ){
        result.push(i);
    }
}
document.write((month 
+ 1+ "月:" + result.join(","));
</script>

 

// 输入框如果输入数字自动三位三位加逗号
<script type="text/javascript">
function onKeyPrice(t) 

    
var stmp = ""
    
if(t.value==stmp)
    {
        
return
    }
    
var ms = t.value.replace(/[^\d\.]/g,"").replace(/(\.\d{2}).+$/,"$1").replace(/^0+([1-9])/,"$1").replace(/^0+$/,"0"); 
    
var txt = ms.split("."); 
    
while(/\d{4}(,|$)/.test(txt[0])) 
    {
       txt[
0= txt[0].replace(/(\d)(\d{3}(,|$))/,"$1,$2"); 
    }
    t.value 
= stmp = txt[0]+(txt.length>1?"."+txt[1]:""); 

</script>
<input name="" type="text" onkeyup="onKeyPrice(this);" />
<asp:TextBox ID="TextBox1" runat="server" onkeyup="onKeyPrice(this);"></asp:TextBox>

 

 

//商品购买 倒计时
商品A   28天8小时6分53秒
商品b   28天8小时6分53秒
商品C   28天8小时6分53秒
商品D   28天8小时6分53秒

<div id='divs'>
<div>商品A   <span> </span> </div><br>
<div>商品b   <span> </span> </div><br>
<div>商品C   <span> </span> </div><br>
<div>商品D   <span> </span> </div></div>
<div id='CountMsg'> </div>

<script language="JavaScript">
function GetRTime(){
var EndTime= new Date("10/11/2009"); //截止时间(月 日 年)
var NowTime = new Date();
var nMS =EndTime.getTime() - NowTime.getTime();
var nD =Math.floor(nMS/(1000 * 60 * 60 * 24));
var nH=Math.floor(nMS/(1000*60*60)) % 24;
var nM=Math.floor(nMS/(1000*60)) % 60;
var nS=Math.floor(nMS/1000) % 60;
var Remain=document.getElementById("divs").getElementsByTagName('SPAN');
if(nD>= 0){
for(var i=0;i <Remain.length;i++){
Remain[i].innerHTML
=nD+''+nH+'小时'+nM+''+nS+'';
}
}
else {
document.getElementById(
"CountMsg").innerHTML="时已过!";

}
setInterval(
"GetRTime()",1000);
}
window.onload
=GetRTime;
</script>

 

 

拍卖网

  剩余时间:<span id='Countdown456'></span> <br />
                          <script>
                              var liftoffTime456 = new Date(2010,5-1,28,17,0,0);
                              var serverdate = new Date(2010,5-1,26,16,43,56);
                                var localdate = new Date();
                                var jtime = localdate-serverdate;
                                liftoffTime456.setUTCSeconds(liftoffTime456.getUTCSeconds()+Math.round(jtime/1000));
                              $(function() {
                              $('#Countdown456').countdown({alwaysExpire: true, until: liftoffTime456, format: 'DHMS', timezone: +8, onExpiry:function(){ liftOff('456')} });
                              });
                          </script>

 

 

一道百度JS大面试题

题目在网页里倒计时显示当年剩下的天时分秒,格式:XX年还剩下X天X时X分X秒

 

距离2011年还有 74 天 14 小时 57 分 37 秒 525
 

 

 

 

代码

 

C#(ASP.NET)公历转农历的简单方法

static string SolarToChineseLunisolarDate(DateTime solarDateTime)
{
    System.Globalization.ChineseLunisolarCalendar cal = new System.Globalization.ChineseLunisolarCalendar();

    int year = cal.GetYear(solarDateTime);
    int month = cal.GetMonth(solarDateTime);
    int day = cal.GetDayOfMonth(solarDateTime);
    int leapMonth = cal.GetLeapMonth(year);
    return string.Format("农历{0}{1}({2})年{3}{4}月{5}{6}"
                        
"甲乙丙丁戊己庚辛壬癸"[(year - 4) % 10]
                        , "子丑寅卯辰巳午未申酉戌亥"[(year - 4) % 12]
                        , "鼠牛虎兔龙蛇马羊猴鸡狗猪"[(year - 4) % 12]
                        , month == leapMonth ? "闰" ""
                        
"无正二三四五六七八九十冬腊"[leapMonth > 0 && leapMonth <= month ? month - 1 : month]
                        , "初十廿三"[day / 10]
                        , "日一二三四五六七八九"[day % 10]
                        );
}

 

使用的方法非常简单:

string 农历 = SolarToChineseLunisolarDate(DateTime.Today);

原文地址:https://www.cnblogs.com/Look_Sun/p/1853965.html