admin管理员组文章数量:1291744
this is my code:
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
alert(minutes+"/"+hours+"/"+month + "/" + day + "/" + year)
but , i think it hard to pare with two time ,
what can i do ?
thanks
this is my code:
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
alert(minutes+"/"+hours+"/"+month + "/" + day + "/" + year)
but , i think it hard to pare with two time ,
what can i do ?
thanks
Share Improve this question asked Aug 29, 2010 at 15:44 zjm1126zjm1126 35.7k53 gold badges125 silver badges167 bronze badges 1- 1 You usually need two quantities in order to perform a parison. So you want to pare the current time to what? – Darin Dimitrov Commented Aug 29, 2010 at 15:46
1 Answer
Reset to default 6If you really want to know whether two Date objects represent precisely the same time, or are before/after one another, it's quite easy: just pare the two Dates via the getTime()
method, which returns an integer timestamp for the object. For example,
var date1 = myDate,
date2 = new Date();
return (date1.getTime() < date2.getTime());
would return true if myDate is before 'now', false if it is now or in the future.
本文标签: javascripthow to get current time and then compare them using jquery Stack Overflow
版权声明:本文标题:javascript - how to get current time and then compare them using jquery- Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741539960a2384262.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论