Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 16:39:18
Original
3088 people have browsed it

Just put the following code in the jsp page

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

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>
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!