大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
使用datediff函数
创新互联公司是专业的新田网站建设公司,新田接单;提供成都网站建设、做网站,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行新田网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
textbox3.text=datediff("d","textbox1.text","textbox2.text")
说明一下:
“d”表示“天”
还可以用“y”,"m","d","h","n","s"
分别表示“年”“月”“日”“时”“分”“秒”
Public Class Form1
Private Past As Date
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Past = Now
IO.File.AppendAllText("test.txt", Past.ToString, System.Text.Encoding.Default)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Now1 As Date = CDate(IO.File.ReadAllText("test.txt", System.Text.Encoding.Default))
Dim Now2 As Date = Now
MsgBox("从" Now1.ToString "到" Now2.ToString "经过了" CStr(CDate((Now2 - Now1).ToString)))
End Sub
实际情况修改下。
End Class
function getTime2Time($time1, $time2)
{
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'));
直接用两个日期相减,返回一个timespan实例,它的Days属性就是天数。
dim d1 as datetime, d2 as datetime
dim days as integer
d1 = DateTime.Today.AddDays(-1)
d2 = DateTime.Today
days = (d2 - d1).Days