Home  >  Article  >  Web Front-end  >  Display morning or afternoon on jsp page based on current time_javascript tips

Display morning or afternoon on jsp page based on current time_javascript tips

WBOY
WBOYOriginal
2016-05-16 16:39:183088browse

Just put the following code in the jsp page

<%
if(new Date().getHours()>=0 && new Date().getHours()<=12){//看看当前时间是在0点到中午12点之间
%>
上午好
<%
}
else{
%>
下午好
<%
}
%>

Application example:

<div class="fitem">
<label>时间类型:</label>
<input id="timeType" name="timeType" class="easyui-combobox" required="true" data-options="
valueField: 'value',
textField: 'label',
value:1,
<%
if(new Date().getHours()>=0 && new Date().getHours()<=12){//看看当前时间是在0点到中午12点之间
%>
data: [{
'label': '上午',
'value': 1,
'selected':true
},{
'label': '下午',
'value': 2
}]"
<%
}
else{
%>
data: [{
'label': '下午',
'value': 2,
'selected':true
}]"
<%
}
%>
/>
</div>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn