function getTime2Time($time1, $time2)
目前成都創(chuàng)新互聯(lián)已為上千多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、雅安服務(wù)器托管、網(wǎng)站托管維護(hù)、企業(yè)網(wǎng)站設(shè)計(jì)、鷹手營子網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
{
var time1 = arguments[0], time2 = arguments[1];
time1 = Date.parse(time1)/1000;
time2 = Date.parse(time2)/1000;
var time_ = time1 - time2;
return (time_/(3600*24));
}
document.write(getTime2Time('2016-08-02', '2016-07-02'));
將時(shí)間轉(zhuǎn)換為指定的字符串格式用:Now.ToString("yyyyMMddHHmmss")就Ok了。
例如:年份用小寫yyyy(大寫不識別),大寫MM識別為月份,小寫mm識別為分鐘,日期天為大寫DD(小寫不識別),
小時(shí)大寫HH識別為24小時(shí)制,小寫hh識別為12小時(shí)制,秒用小寫ss(大寫不識別)
補(bǔ)充:Visual Basic.NET是基于微軟.NET Framework之上的面向?qū)ο蟮木幊陶Z言。
其在調(diào)試時(shí)是以解釋型語言方式運(yùn)作,而輸出為EXE程序是是以編譯型語言方式運(yùn)作。
可以看作是Visual Basic在.Net Framework平臺(tái)上的升級版本,增強(qiáng)了對面向?qū)ο蟮闹С帧4蠖嗟腣B.Net程序員使用Visual Studio .Net作為IDE(integrated development environment).SharpDevelop是另一種可用的開源的IDE。
VB.Net需要在.Net Framework平臺(tái)上才能執(zhí)行。
Public Class Form1
Private Function ZToFSAll(ByVal ZT As Long) As String
'全存樣式
'從天,時(shí),分,秒整合為秒
Dim T, S, F, M As Integer '天,時(shí),分,秒
Dim T1, S1 As Integer '天,時(shí),分,秒
Dim M1 As String
T = ZT \ 86400
T1 = ZT Mod 86400
S = T1 \ 3600
S1 = T1 Mod 3600
F = S1 \ 60
M = S1 Mod 60
If M 10 Then
M1 = "0" M
Else
M1 = M
End If
ZToFSAll = T "天" S "小時(shí)" F "分鐘" M1 "秒"
End Function
Private Function ZToFSQS(ByVal ZT As Long) As String
'缺損樣式
'從秒分解為天,時(shí),分,秒
Dim T, S, F, M As Integer '天,時(shí),分,秒
Dim T1, S1 As Integer '天,時(shí),分,秒
Dim T2, S2, F2, M2 As String '天,時(shí),分,秒
T = ZT \ 86400
T1 = ZT Mod 86400
S = T1 \ 3600
S1 = T1 Mod 3600
F = S1 \ 60
M = S1 Mod 60
If T = 0 Then
T2 = ""
Else
T2 = T "天"
End If
If S = 0 Then
S2 = ""
Else
S2 = S "小時(shí)"
End If
If F = 0 Then
F2 = ""
Else
F2 = F "分鐘"
End If
M2 = M "秒"
ZToFSQS = T2 S2 F2 M2
End Function
Private Function FSoZT(ByVal T As Integer, ByVal S As Int16, ByVal F As Int16, ByVal M As Int16) As Long
'從天,時(shí),分,秒分解為秒
'T, S, F, M分別為天,時(shí),分,秒
FSoZT = T * 86400 + S * 3600 + F * 60 + M
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = ZToFSQS(520354) '值為:6天32分鐘34
TextBox1.Text = ZToFSAll(520354) '值為:6天0小時(shí)32分鐘34秒
TextBox1.Text = FSoZT(6, 0, 32, 34) '值為:520354
End Sub。
使用datediff函數(shù)
textbox3.text=datediff("d","textbox1.text","textbox2.text")
說明一下:
“d”表示“天”
還可以用“y”,"m","d","h","n","s"
分別表示“年”“月”“日”“時(shí)”“分”“秒”
假設(shè)你得到 N 秒
那么,一個(gè)小時(shí)就是 3600 秒,一分鐘就是 60 秒,我們就可以這樣子分割出來 :
小時(shí) hour = N / 3600;
分鐘 minute = ( N - ( hour * 3600 ) ) / 60;
秒 second = N - ( hour * 3600 + minute * 60 );
然后自己按照 hour : minute : second 的格式打印出來就行了 。