unix时间戳是从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数,不考虑闰秒. 在大多数的UNIX系统中UNIX时间戳存储为32位,这样会引发2038年问题. 但是,因为需求是需要int类型的UNIX时间戳. 开始的时候我是这样设计的. /** * 获取当前事件Unxi 时间戳 * @return */ public static int getUnixTimeStamp(){ long rest=System.currentTimeMillis()/1000L; return (i
方法一可以使用date的getTime()方法来将当前日期格式的时间转换为毫秒数,进而相减. long systime = new Date().getTime();//当前系统时间 long oldtime = old.getTime();//相比较的时间 Long time = (systime - oldtime);//相差毫秒数 方法二则使用calendar 的getTimeInMillis() 方法来将当前日期格式的时间转换为毫秒数. Calendar no
public static final int YEAR_RETURN = 0; public static final int MONTH_RETURN = 1; public static final int DAY_RETURN = 2; public static final int HOUR_RETURN= 3; public stat
var str = '2008-10-09 21:35:28';//PHP中对应的UNIX时间戳为1223559328 var new_str = str.replace(/:/g,'-'); new_str = new_str.replace(/ /g,'-'); var arr = new_str.split("-"); document.write("<b>原始日期</b>: "+str); var datum = new Date(D