JavaScript getTime() 方法

本文深入解析JavaScript中用于获取自1970年1月1日以来的毫秒数的日期方法getTime(),包括其定义、语法、返回值及实际应用示例。

定义和用法

getTime() 方法可返回距 1970 年 1 月 1 日之间的毫秒数。

语法


dateObject.getTime()

返回值

dateObject 指定的日期和时间距 1970 年 1 月 1 日午夜(GMT 时间)之间的毫秒数。

提示和注释:

注释:该方法总是结合一个 Date 对象来使用。

实例

例子 1

在本例中,我们将取得从 1970/01/01 至今的毫秒数,并输出它:


<script type="text/javascript"> var d = new Date() document.write(d.getTime() + " milliseconds since 1970/01/01") </script>

输出:


1363835442793 milliseconds since 1970/01/01
<template v-if="item.fieldtype == 'Date'"> <el-date-picker :placeholder="$t('msg.开始日期')" :style="{ 'width': '140px' }" format="YYYY-MM-DD" type="date" v-model="form[item.valueName][0]" value-format="YYYY-MM-DD" :disabled-date="(time) => disableStartDate(time, item.valueName,item.fieldtype)" /> &nbsp;—&nbsp; <el-date-picker :placeholder="$t('msg.结束日期')" :style="{ 'width': '140px' }" format="YYYY-MM-DD" type="date" v-model="form[item.valueName][1]" value-format="YYYY-MM-DD" :disabled-date="(time) => disableEndDate(time, item.valueName,item.fieldtype)" /> </template> <template v-if="item.fieldtype == 'DateTime'"> <el-date-picker :placeholder="$t('msg.开始日期')" :style="{ 'width': '180px' }" format="YYYY-MM-DD HH:mm:ss" type="datetime" v-model="form[item.valueName][0]" value-format="YYYY-MM-DD HH:mm:ss" :disabled-date="(time) => disableStartDate(time, item.valueName,item.fieldtype)" /> &nbsp;—&nbsp; <el-date-picker :placeholder="$t('msg.结束日期')" :style="{ 'width': '180px'}" format="YYYY-MM-DD HH:mm:ss" type="datetime" v-model="form[item.valueName][1]" value-format="YYYY-MM-DD HH:mm:ss" :disabled-date="(time) => disableEndDate(time, item.valueName,item.fieldtype)" /> </template> 优化日期和日期时间选择, 如果第一个选择了日期 则第二个日期只能选择大于他的 同理 第二个先选择了 则第一个只能选择小于该日期的,且日期时间类型 需要精确到秒,即第一个日期选择了2025-03-28 05:00:00 第二个日期只能选择该日期和时间后面的 封装方法 Date类型的 是可以选择同一天的,DateTime也是可以选择同一个时间的
03-29
<%@page import="com.haitaiinc.inpordnurse.ylz.dto.common.Bm_ygxx00DTO"%> <%@page import="com.haitaiinc.common.CommUtil"%> <%@ page import="com.haitaiinc.servlet.JSP,com.haitaiinc.util.Dict,com.haitaiinc.htdb.sd_haitai2.dto.*"%> <%@page import="com.haitaiinc.htdb.sd_haitai2.dto.Inpatient"%> <%@page import="com.haitaiinc.common.CommonAction"%> <%@page import="com.haitaiinc.htcpoe.InpordSystemConfig"%> <%@page import="com.haitaiinc.util.Dict"%> <%@page import="com.haitaiinc.Util"%> <%@page import="java.text.SimpleDateFormat"%> <%@page import="java.util.Calendar"%> <%@page import="java.util.Date"%> <%@page import="java.util.List"%> <%@page import="java.util.ArrayList"%> <%@page import="com.haitaiinc.servlet.JSP"%> <%@page import="com.haitaiinc.common.Const"%> <%@page import="com.haitaiinc.util.Dict"%> <%@page import="com.haitaiinc.inpordnurse.ylz.dto.yrqd.Bm_bqks00DTO"%> <jsp:useBean id="token" class="java.lang.String" scope="request"></jsp:useBean> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=7" ></meta> <%=JSP.getHtCSSDef(request)%> <%=JSP.getPageCSSDef(request) %> <%=JSP.getHtJSDef(request)%> <script src="ht-5.0/ht-core.js" type="text/javascript"></script> <script src="<%=request.getContextPath() %>/js/jquery-1.8.3.js"></script> <script src="<%=request.getContextPath() %>/js/jquery-ui-1.11.4/jquery-ui.js"></script> <link href="<%=request.getContextPath() %>/js/jquery-ui-1.11.4/jquery-ui.css" rel="stylesheet" type="text/css" /> <script src="<%=request.getContextPath() %>/js/showLoading.js"></script> <script src="<%=request.getContextPath() %>/js/orderdrug/common-edit-drug.js"></script> <script src="/nurse-business-extend/extendforylz/commjs/nurse-synthetical-oprate.js"></script> <% String titleName = "病区收入统计"; String currentTime = Util.getCurrentDate("yyyy-MM-dd"); SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar=Calendar.getInstance(); String currentday = simpleDateFormat.format(calendar.getTime()); calendar.add(Calendar.MONTH,-1); String lastmonth = simpleDateFormat.format(calendar.getTime()); //医嘱检索结果区下方增加空白区域显示医嘱的特殊说明 String showDesc = "false"; showDesc = "true"; List<Bm_bqks00DTO> bqksList = (ArrayList)request.getAttribute("bqksList"); List<Bm_ygxx00DTO> yhryList = (ArrayList)request.getAttribute("yshsList"); String[] monthsList = {"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"}; %> <title><%=titleName%></title> <script type="text/javascript" src="js/json2.js"></script> <script type="text/javascript"> </script> <style> html{height:100%;overflow:hidden;} .div-radio { margin: 0px 0px 0px 0px; } .div-inline1{ margin-top: 5px; margin-left: -6px; padding-left: 10px; height: 25px; } </style> </head> <body style="height:100%"> <div id="qrDiv" style="height:100%;"> <form name="searchForm" id="searchForm" method="post"> <table cellpadding="1" cellspacing="1" style="table-layout: fixed;width: 100%; height:100%;"> <colgroup> <col id="colId" width="100%"> </colgroup> <tr> <td class="main_bg_search" style="width: 100%;" colspan="2"> <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td> <div class="div-inline"> &nbsp;科室: <select id="bqks" name="bqks" style="width: 120px;height: 23px;" onchange="changeYhry(this);"> <option selected="selected" value="">全部</option> <% for(int j=0; bqksList!=null&&j<bqksList.size();j++){ Bm_bqks00DTO sd = bqksList.get(j); %> <option value="<%=Util.toString(sd.getKsh000()) %>"><%=Util.toString(sd.getBmmc00()) %></option> <%} %> </select> </div>&nbsp; <div class="div-inline"> <span> <label><input type="radio" style="margin-left: -10px;" name="itemStatus" value="xmlb" checked="checked" onclick="checkYhry(this);searchList();"/>按项目类别</label> <label><input type="radio" name="itemStatus" value="jtxm" onclick="checkYhry(this);searchList();" />按具体项目</label> <label><input type="radio" name="itemStatus" value="yhry" onclick="checkYhry(this);searchList();" /> 按医护人员: <select id="yhry" name="yhry" disabled="disabled" style="width: 120px;height: 23px;"> <option selected="selected" value="">全部</option> <% for(int j=0; yhryList!=null&&j<yhryList.size();j++){ Bm_ygxx00DTO sd = yhryList.get(j); %> <option value="<%=Util.toString(sd.getYgbh00()) %>"><%=Util.toString(sd.getZwxm00()) %></option> <%} %> </select> </label> </span> </div>&nbsp; </td> </tr> <tr> <td> &nbsp;&nbsp; <div class="div-inline div-checkbox-or-radio div-inline1"> <span> <label><input type="radio" checked="checked" style="margin-left: -10px;" name="timeTypes" value="0" onclick="checkTime(this);"/> 月份: <select id="months" name="months" style="width: 120px;height: 22px;margin-top: 1px;"> <option selected="selected" value="0">当前月份</option> <% for(int j=0; monthsList!=null&&j<monthsList.length;j++){ %> <option value="<%=j+1 %>"><%=monthsList[j] %></option> <%} %> </select> </label> </span> </div>&nbsp;&nbsp; <div class="div-inline div-checkbox-or-radio div-inline1" style="margin-bottom: 3px;"> <span> <label><input type="radio" style="margin-left: -10px;" name="timeTypes" value="1" onclick="checkTime(this);"/> 时间: <input type="text" readonly name="startTime" id="startTime" style="width: 100px;" disabled="disabled" onclick="fPopUpCalendarDlg(startTime);searchList();" value="<%=Util.format(lastmonth, "yyyy-MM-dd")%>" /> -&nbsp;<input type="text" readonly name="endTime" id="endTime" style="width: 100px;" disabled="disabled" onclick="fPopUpCalendarDlg(endTime);searchList();" value="<%=Util.format(currentday, "yyyy-MM-dd")%>" /> </label> </span> </div> <div class="div-inline" style="margin-bottom: 5px;"> <input type="button" class="order_button" value="查&nbsp;&nbsp;询" id='queryBtn' onclick="searchList();"/>&nbsp;&nbsp; <input type="button" class="order_button" value="导出Excel" id='exportExcelBtn' onclick="exportExcel();"/>&nbsp;&nbsp; </div> </td> </tr> </table> </td> </tr> <tr id="listTr"> <td id="dataTd" height="84.5%" width="100%" align="left" valign="top"> <table cellpadding="1" cellspacing="1" style="table-layout: fixed;width: 100%; height:100%;"> <tr> <td height="100%" width="100%" ><!-- 医嘱信息展示列表区 --> <div id="listshow" style="overflow:hidden;height:100%;width:100%;" ></div> </td> </tr> </table> </td> </tr> </table> </form> </div> <div id="swElement" style="display: none;"> </div> </body> <script type="text/javascript"> var token = "<%=token%>"; var menu = "<%=titleName%>"; searchList(); //展示统计列表 function searchList(){ showLoading(); var url = "do?module=inpordnurse&action=YlzBqsrtj&method=searchIncomeStatisticsList"; $("#listshow").html(""); Haitai.Ajax.request({ url : url, params:{ token:token }, form : searchForm, callback : function(text){ closeLoading(); ht("listshow").html(text,false); } }); } function checkYhry(obj){ if(obj.value=="xmlb"&&obj.checked){ $("#yhry").attr("disabled",true); }else if(obj.value=="jtxm"&&obj.checked){ $("#yhry").attr("disabled",true); }else{ $("#yhry").attr("disabled",false); } } function checkTime(obj){ if(obj.value=="0"&&obj.checked){ $("#startTime").attr("disabled",true); $("#endTime").attr("disabled",true); $("#months").attr("disabled",false); }else{ $("#startTime").attr("disabled",false); $("#endTime").attr("disabled",false); $("#months").attr("disabled",true); } searchList(); } function checkIsNull(str){ if(str==null||str==""||str==undefined){ return true; }else{ return false; } } //选择科室联动变化医护人员下拉框数据,护士不变,医生随科室切换变化 function changeYhry(obj){ var xzks00 = obj.value; if(xzks00!=""){ var url = "do?module=inpordnurse&action=YlzBqsrtj&method=searchYhryByXzks"; Haitai.Ajax.request({ url : url, params:{ token:token, xzks00:xzks00 }, form : searchForm, callback : function(text){ if(checkIsNull(text)){ var yhryObj = $("#yhry"); yhryObj.html(""); yhryObj.append($("<option selected=\"selected\" value=\"\">全部</option>")); }else{ var retJson = eval("("+text+")"); var yhryObj = $("#yhry"); yhryObj.html(""); yhryObj.append($("<option selected=\"selected\" value=\"\">全部</option>")); for(var i=0;i<retJson.length;i++){ yhryObj.append($("<option value=\""+retJson[i].ygbh00+"\">"+retJson[i].zwxm00+"</option>")); } } } }); } } function exportExcel(){ } </script> </html>exportExcel帮我导出excel
最新发布
07-16
以下源码的用户和密码分别是:<!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="zh-CN" lang="zh-CN"> <head> <meta HTTP-EQUIV="Pragma" CONTENT="no-cache"> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=GBK"> <title>安邦系统平台入口-登录验证</title> <style> *{margin:0px;padding:0px;} html,body{margin:0px; padding:0px;height:100%;width:100%;border:0px;} body{background:#6c6c6c;height:100%;width:100%;overflow:hidden;} .LoginDIV{width:700px;margin:0px auto;;padding:0px;overflow:hidden;} .FootDIV {width:700px;margin:0px auto;;padding:0px;overflow:hidden;text-align:center;} .TextInput{padding:3px 0px 3px 5px;width:100px;border-left:solid 1px #444444;border-top:solid 1px #444444;border-right:solid 1px #ffffff;;border-bottom:solid 1px #ffffff;font-size:13px;text-align:center;} </style> <script type="text/javascript" src="/js/jquery-1.8.3.min.js"></script> <script language='JavaScript'> function getObjByID(Id){if('object'==typeof(Id))return Id;else if('string'==typeof(Id))return document.getElementById(Id);else return null;} function SetCookie(inc_Name,INC_Value,INC_Hours) {   var TheEXP = new Date();   TheEXP.setTime(TheEXP.getTime() + 60*60*1000*INC_Hours);   document.cookie= inc_Name + "=" + INC_Value + ";expires="+ TheEXP.toGMTString(); } function GetCookie(inc_Name) {   var cookieString = new String(document.cookie);   var cookieHeader = inc_Name + "=";   var beginPosition = cookieString.indexOf(cookieHeader);   if (beginPosition != -1) { cookieString=cookieString.substring(beginPosition + cookieHeader.length); beginPosition=cookieString.indexOf(";") if (beginPosition != -1){cookieString=cookieString.substring(0,beginPosition);} return cookieString; }   else {return "";} } function GetAllCookie() { var CookieUserName=GetCookie('CKUserName'); var CookieUserPass=GetCookie('CKUserPass'); var CookieKeepMyInfo=GetCookie('CKKeepMyInfo'); document.getElementById('UserName').value=CookieUserName; document.getElementById('UserPass').value=CookieUserPass; if (CookieKeepMyInfo.replace(/\s*/,'')=='1') {document.getElementById('KeepMyInfo').value==1;} else {document.getElementById('KeepMyInfo').value==0;} } function CheckForm(inc_form) { var FOBJ=document.getElementById(inc_form); var UserName=FOBJ.UserName.value.replace(/\s*/g,''); var UserPass=FOBJ.UserPass.value.replace(/\s*/g,''); if (UserName==''){alert('请输入帐号');FOBJ.UserName.value='';FOBJ.UserName.focus();return false;} if (UserPass==''){alert('请输入密码');FOBJ.UserPass.value='';FOBJ.UserPass.focus();return false;} if (UserPass==''){alert('请输入密码');FOBJ.UserPass.value='';FOBJ.UserPass.focus();return false;} if (document.getElementById('KeepMyInfo').value==1) { SetCookie("CKUserName",UserName,48); SetCookie("CKUserPass",UserPass,48); SetCookie("CKKeepMyInfo",1,48); } else { SetCookie("CKUserName","",48); SetCookie("CKUserPass","",48); SetCookie("CKKeepMyInfo",0,48); } return true; } function CheckKeydown(inc_event,inc_NextOBJ,inc_FS) { if (inc_event.keyCode==13) { if (inc_FS==0) {document.getElementById(inc_NextOBJ).focus();} else { if(CheckForm(inc_NextOBJ)){document.getElementById(inc_NextOBJ).submit();} } } } function resizeWindow() { var BodyHeight=0; var TopDIVHeight=0; var LoginDIVHeight=0; var IMGLaoYingHeight=0; var IMGLaoYingWidth=0; BodyHeight=$("body").height(); LoginDIVHeight=$("#LoginDIV").height(); IMGLaoYingHeight=$("#IMGLaoYing").height(); TopDIVHeight=BodyHeight-LoginDIVHeight; var IMGMarginTop= (TopDIVHeight-IMGLaoYingHeight)/2.5 + 'px'; $("#TopDIV").height(TopDIVHeight); $("#IMGLaoYing").css("margin-top",IMGMarginTop); } $(document).ready(function(){resizeWindow();}); $(window).resize(function() {resizeWindow();}); </script> </head> <body onload="GetAllCookie();document.getElementById('UserName').focus();"> <div id="TopDIV" style="overflow:hidden;text-align:center;background:#000000;margin:0px auto;width:100%;background:#000000;height:70%"> <img id='IMGLaoYing' src="/images/laoying.png" style="height:55%;max-width:650px;"> </div> <div id="LoginDIV" style="overflow:hidden;text-align:center;background:#000000;margin:0px auto;width:100%;background:#c07814;height:200px"> <div style="overflow:hidden;height:50px;">&nbsp;</div> <div style="overflow:hidden;margin:0px auto;width:500px;text-align:center;border:solid 0px #000000"> <form method='post' id='LogForm' name='LogForm' action='CheckPWD.php' style='margin:0px;padding:0px;overflow:hidden;'> <div style="overflow:hidden;float:left;margin-left:5px;"></div> <div style="overflow:hidden;float:left;font-size:13px;padding-top:3px;color:#222222;font-weight:bold;font-family:'Microsoft YaHei' ! important;">用&nbsp;&nbsp;户:</div> <div style="overflow:hidden;float:left;margin-left:5px;"><Input Type="Text" class="TextInput" name="UserName" id="UserName" value="" maxlength="30" onkeydown="CheckKeydown(event,'UserPass',0);"></div> <div style="overflow:hidden;float:left;width:60px;">&nbsp;</div> <div style="overflow:hidden;float:left;font-size:13px;padding-top:3px;color:#222222;font-weight:bold;font-family:'Microsoft YaHei' ! important;">密&nbsp;&nbsp;码:</div> <div style="overflow:hidden;float:left;margin-left:5px;"><Input Type="password" class="TextInput" name="UserPass" id="UserPass" value="" maxlength="30" onkeydown="CheckKeydown(event,'LogForm',1);"></div> <div style="overflow:hidden;float:left;width:55px;">&nbsp;</div> <div style="overflow:hidden;float:left;"> <Input Type="button" value=" 确 认 " onclick="if(CheckForm('LogForm')){LogForm.submit();}" style="width:80px;height:25px;background:#900a12;border:solid 0px #ffffff;font-size:13px;color:#ffffff;font-weight:bold;font-family:'Microsoft YaHei' ! important;"> <input type="hidden" id="KeepMyInfo" name="KeepMyInfo" value="1"> </div> </form> </div> <div style="clear:both;overflow:hidden;height:50px;"></div> <div style="overflow:hidden;text-align:center;font-size:12px;color:#333333">安邦咨询(ANBOUND)内部管理系统,&copy 2025</div> </div> </body> </html>
05-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值