Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

ความแตกต่างระหว่าง datetime และ datetime-local ใน HTML5

datetime

วันที่และเวลา (ปี, เดือน, วัน, ชั่วโมง, นาที, วินาที, fractions of a second) เข้ารหัสตาม ISO 8601 time zone ตั้งเป็น UTC

ตัวอย่าง:

<!DOCTYPE HTML>
<html>
  <body>
    <form action="/cgi-bin/html5.cgi" method="get">
      Date and Time: <input type="datetime" name="newinput" />
      <input type="submit" value="submit" />
    </form>
  </body>
</html>

datetime-local

วันที่และเวลา (ปี, เดือน, วัน, ชั่วโมง, นาที, วินาที, fractions of a second) เข้ารหัสตาม ISO 8601 ไม่มี time zone information

ตัวอย่าง:

<!DOCTYPE HTML>
<html>
  <body>
    <form action="/cgi-bin/html5.cgi" method="get">
      Local Date and Time: <input type="datetime-local" name="newinput" />
      <input type="submit" value="submit" />
    </form>
  </body>
</html>