最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Return only time irrelevant date javascript - Stack Overflow

programmeradmin5浏览0评论

My question is more about logic not code.I created something called prepared messages with time i supply to each new message, i pare the time with current time and give each row a background. Is it possible for me to fetch the time with javascript only the current time NO DATE. Regards

My question is more about logic not code.I created something called prepared messages with time i supply to each new message, i pare the time with current time and give each row a background. Is it possible for me to fetch the time with javascript only the current time NO DATE. Regards

Share Improve this question asked Jan 24, 2010 at 19:26 SarahSarah 4952 gold badges11 silver badges23 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 2

To pare only the time, without year, month and day taken into account, try the following:

var now = new Date().setFullYear(1, 0, 1)
,   andThen = new Date(dateMessageSent).setFullYear(1, 0, 1)

if (now > andThen) doYourStuff()

Yes, see Date.getTime()

d = new Date();
var time=d.toTimeString();

Take a look at the Date Object and in particular the following methods

  1. toTimeString()
  2. getHours()
  3. getMinutes()
  4. getSeconds()
发布评论

评论列表(0)

  1. 暂无评论