Displays morning or afternoon on the JSP page based on the current time
- 2020-03-30 03:42:10
- OfStack
As long as in the JSP page if the following code line
<%
if(new Date().getHours()>=0 && new Date().getHours()<=12){//Let's see the current time is between 0 and 12 noon
%>
Good morning
<%
}
else{
%>
Good afternoon,
<%
}
%>
Examples of application:
<div class="fitem">
<label> Time to type :</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){//Let's see the current time is between 0 and 12 noon
%>
data: [{
'label': ' In the morning ',
'value': 1,
'selected':true
},{
'label': ' In the afternoon ',
'value': 2
}]"
<%
}
else{
%>
data: [{
'label': ' In the afternoon ',
'value': 2,
'selected':true
}]"
<%
}
%>
/>
</div>