Hiển thị Date & Time với ASP

Để hiển thị Ngày tháng năm hiện tại ta có thể dùng hàm Date() và Thời gian với Hàm Time(). Còn để hiển thị cùng lúc Ngày tháng năm và Thời gian ta có thể dùng Hàm Now().


Ngòai ra bằng cách dùng các tham số và mệnh đề điều kiện, ta có thể biến hóa để hiển thị Date và Time theo ý muốn.

Dưới đây là bảng hướng dẫn sử dụng hai Hàm này:

Ví Dụ: Viết Kết Quả Hiển Thị:
<%= time()%> Time()Giờ trên Server)
<%=date()%> " & Date() & "
<%=now()%> 9/17/2006 11:25:16 PM
<% Response.Write("Ngày giờ hiện tại: "&now())%> Ngày giờ hiện tại(Server): 9/17/2006 11:25:16 PM
<%= FormatDateTime(Date, 0)%> 9/17/2006
<%= FormatDateTime(Date, 1)%> Sunday, September 17, 2006
<%= FormatDateTime(now, 3)%> 11:25:16 PM
<%= FormatDateTime(now, 4)%> 23:25
<%response.write("Day of the week: "&WeekDay(Date))%> Day of the week: 1
<%response.write("Day of the month: "&Day(Date))%> Day of the month: 17
<%response.write("Current Year: "&Year(Date))%> Current Year: 2006
<%response.write("Current Year: "&Right(Year(Date),2))%> Current Year: 06
<%response.write("Today is: "&WeekDayName(WeekDay(Date)))%> Today is: Sunday
<%response.write("Hour Part: "&(hour(now)))%> Hour part: 23
<%response.write("Minute Part: "&Minute(now()))%> Minute part: 25
<%response.write("Second Part: "&Second(now()))%> Second part: 16


This entry was posted on 02:27 and is filed under .Follow any comments here with the RSS 2.0 . You can leave a response so that we can know your suggestion.
0 Responses to "Hiển thị Date & Time với ASP"

Đăng nhận xét