有没有一种方法可以根据时间从HTML获取自动字符串

时间:2020-02-24 09:33:39

标签: html sql datetime

我正在寻找类似于html中SQL的解决方案 例如在SQL

Case when date between 00:00:00 and 12:00:00 then "morning"
else "afternoon"
end as Morning/afternoon

2 个答案:

答案 0 :(得分:1)

在Java脚本标签中尝试一下:

    var myDate = new Date();
    var hrs = myDate.getHours();
    var greet;

    if (hrs >= 12 && hrs <= 11.59)
        greet = 'Good Morning';
    else if (hrs >= 12 && hrs <= 17)
        greet = 'Good Afternoon';
    else if (hrs >= 17 && hrs <= 24)
        greet = 'Good Evening';

    document.getElementById('TIME').innerHTML = greet;

答案 1 :(得分:1)

您可以使用带有HTML的JavaScript代码来实现自己的目标,如下所示。

<div class="row">
    <div class="container Col-md-12 col-lg-12" style=" max-width: 80em;  ">
        <h1 class="heading " style="margin: 2em 10em 0em 9em;"> pacakges</h1>
        <div class="row-heading Col-md-12" style=" max-width: 80em;">
        </div>
        <div class="filters col-md-3 col-lg-3" style="margin-left: 1em; max-width: 20em;">Filters
            <h4> Category </h4>
            <label class="container ">
                <input type="checkbox" checked="checked"> Family
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> Friends
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> Couple
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> solo
                <span class="checkmark"></span>
            </label>
            <h4> Activity </h4>
            <label class="container">
                <input type="checkbox" checked="checked"> Adventure
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> Hill Station
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> Nature
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> Historical places
                <span class="checkmark"></span>
            </label>
            <h4> Duration </h4>
            <label class="container">
                <input type="checkbox" checked="checked"> 1 t0 3 days
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> 3 to 5 days
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> 7 to 10 days
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> more than 10 days
                <span class="checkmark"></span>
            </label>
            <h4> Stay Type </h4>
            <label class="container">
                <input type="checkbox" checked="checked"> Hotel
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> Homestay
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> Camping
                <span class="checkmark"></span>
            </label>
            <label class="container">
                <input type="checkbox"> Rooms
                <span class="checkmark"></span>
            </label>
        </div>
        <div class=" Packages-details col-md-9 col-lg-9 bg-info " style="margin-left:  23em; max-width: 60em; ">
            <h4 class=" col-md-6 " style="margin-top: 0em;">Pacakges details</h4>
        </div>
    </div>
</div>