1、
<script language="javascript">
var mydate = new date();
mydate.getyear(); //获取当前年份(2位)
mydate.getfullyear(); //获取完整的年份(4位,1970-????)
mydate.getmonth(); //获取当前月份(0-11,0代表1月)
mydate.getdate(); //获取当前日(1-31)
mydate.getday(); //获取当前星期x(0-6,0代表星期天)
mydate.gettime(); //获取当前时间(从1970.1.1开始的毫秒数)
mydate.gethours(); //获取当前小时数(0-23)
mydate.getminutes(); //获取当前分钟数(0-59)
mydate.getseconds(); //获取当前秒数(0-59)
mydate.getmilliseconds(); //获取当前毫秒数(0-999)
mydate.tolocaledatestring(); //获取当前日期
var mytime=mydate.tolocaletimestring(); //获取当前时间
mydate.tolocalestring( ); //获取日期与时间
if (mytime<"23:30:00")
{
alert(mytime);
}
</script>
2、
<%
java.text.simpledateformat formatter = new java.text.simpledateformat("yyyy-mm-dd hh:mm:ss");
java.util.date currenttime = new java.util.date();//得到当前系统时间
string str_date1 = formatter.format(currenttime); //将日期时间格式化
string str_date2 = currenttime.tostring(); //将date型日期时间转换成字符串形式
%>
以上就是小编为大家带来的在jsp页面中获取当前日期时间的方法的全部内容了,希望对大家有所帮助,多多支持硕编程~
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!