如何从两个日期时间找到分钟 [英] How to find minutes from two Datetime

查看:62
本文介绍了如何从两个日期时间找到分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何找到以下场景中两个日期时间的分钟数。



日期1: 2015-12-31 21:00:00

日期2: 2016-01-01 05:00:00



请提供您宝贵的意见。



谢谢,

Sivasankaran G

Hi,

How to find the minutes from two Datetime for the following scenerio.

Date1: 2015-12-31 21:00:00
Date2: 2016-01-01 05:00:00

Kindly provide your valuable feedback.

Thanks,
Sivasankaran G

推荐答案

这是一个非常容易用Google搜索的问题,可以节省您的时间,也可以帮助您了解更多信息。



基本上将两者都转换为日期然后减去它们。



This is the kind of question that is very easily googled for and can save you time and will also help you learn more.

Essentially convert both to dates and then subtract them.

var Date1 = new Date(2015, 12, 31);
var Date2 = new Date(2016, 01, 01);
alert(Date2 - Date1);





参见 datetime - JavaScript中日期之间的差异 - 堆栈溢出 [ ^ ]了解更多示例。



另请参阅JavaScript日期 [ ^ ]关于日期的好资源。



See datetime - Difference between dates in JavaScript - Stack Overflow[^] for more examples.

Also refer to JavaScript Dates[^] for a good resource on dates.


如果你想找到当天的部分时间你可以找到如下所示



If you want to find minutes part of the day you can find like below

//var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
var d = new Date(2014, 5, 22, 09, 45, 11, 23);

d.getMinutes();


这篇关于如何从两个日期时间找到分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆