关于时间的几个小应用函数
编辑时间:2017-03-26 作者:金满斗 浏览量:1834 来源:原创
  1. import console; 

  2. var num = 1475929480;

  3. console.log(num,time(num,"%Y-%m-%d %H:%M:%S") );

  4. console.pause(true);

通过时间戳返回时间

通过网站的返回头文件获取时间

  1. getTime = function(url){    

  2.     var whttp = inet.whttp()    

  3.     whttp.beginRequest(url,"GET")

  4.     whttp.send()

  5.     var da = whttp.readHeader("Date")   

  6.     setlocale("time","enu")

  7.     var tm = time(da,"%a, %d %b %Y %H:%M:%S")

  8.     setlocale("time","chs")

  9.   tm = time(tonumber(tm))

  10.     tm.format="!%c";//说明这是一个UTC时间 

  11. tm.local(); //转换为本地时间

  12. tm.format= "%Y-%m-%d %H:%M:%S"

  13.     return tm;    

  14. }


来说两句吧