Fungsi VBScript IsDate
kembali fungsi IsDate menunjukkan apakah ekspresi perhitungan ke tanggal nilai Boolean. Jika ekspresi adalah tanggal atau dapat dikonversi ke tanggal, ia mengembalikan Benar. Jika tidak, ia mengembalikan palsu.
Catatan: Fungsi IsDatemenggunakan pengaturan lokal untuk mendeteksi apakah string dapat dikonversi ke tanggal (dalam semua bahasa, "Januari" tidak satu bulan).
tatabahasa
IsDate(expression)
参数 | 描述 |
---|---|
expression | 必需。要计算的表达式。 |
contoh 1
Tanggal yang sah:
<script type="text/vbscript">
document.write(IsDate("April 22, 1947"))
document.write("<br />")
document.write(IsDate(#01/31/10#))
</script>
document.write(IsDate("April 22, 1947"))
document.write("<br />")
document.write(IsDate(#01/31/10#))
</script>
Contoh output di atas:
True
True
True
Coba »
contoh 2
Tanggal ilegal:
<script type="text/vbscript">
document.write(IsDate("#01/31/10#"))
document.write("<br />")
document.write(IsDate("52/17/2010"))
document.write("<br />")
document.write(IsDate("Hello World!"))
</script>
document.write(IsDate("#01/31/10#"))
document.write("<br />")
document.write(IsDate("52/17/2010"))
document.write("<br />")
document.write(IsDate("Hello World!"))
</script>
Contoh output di atas:
False
False
False
False
False
Coba »
Lengkap VBScript Referensi