<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script type="text/javascript"> var getOffDays = function(startDate, endDate) { var mmSec = (endDate.getTime() - startDate.getTime()); //得到时间戳相减 得到以毫秒为单位的差 return (mmSec / 3600000 / 24); //单位转换为天并返回 }; alert(getOffDays(new Date(2009,1,1), new Date(2009,2,1))); alert(getOffDays(new Date(2009,2,1), new Date(2009,3,1))); alert(getOffDays(new Date(2009,11,1), new Date(2009,12,1))); alert(getOffDays(new Date(2009,11,10), new Date(2009,12,10))); </script> </head> <body> </body> </html>
转载于:https://www.cnblogs.com/vibratea/archive/2010/09/16/1827729.html
转载请注明原文地址: https://win8.8miu.com/read-17100.html