asp.net获取系统当前时间的方法:
DateTime.Now.ToString(); // 2008-9-4 20:02:10
DateTime.Now.ToLocalTime().ToString(); // 2008-9-4 20:12:12
写在js中:
//时间戳 日志用
var tm1 = new Date().getTime();
function getData(n) {
n = new Date(n)
return n.toLocaleDateString().replace(/\//g, "-") + " " + n.toTimeString().substr(0, 8)
}
tm2 = getData(tm1) //'2022-1-18 10:09:06'
alert(tm2);
写在 *.aspx.cs中
protected void Page_Load(object sender, EventArgs e)
{
//日志记入
String strTest = "被修改";
String ts1 = DateTime.Now.ToString();
System.IO.File.WriteAllText(@"D:\VS2015\SSC3\log.txt", '\n' + ts1 + "_" + strTest);
}