ASP Format Date and Time Script

xiaoxiao2021-03-06  43

ASP HAS A VERY HANDY Inbuild Function Called Formator ().

Let's start with the now () Function to get the current date and time Into a variable

<%

DIM TodaySdate

TodaySdate = now ()

%>

Now We can use the formatdatetime function to format ot date variable in a variety of ways.

First Let's See How TodaySdate Appears:

<%

Response.write todaysdate

%>

Result: 2/14/2005 12:34:41 PM

Using 0 - The VbGneraldDate Format Creates A Date As Short Date (if include), and Time As long time.

<% Response.write formatdatetime (TodaySdate, 0)

%>

Result: 2/14/2005 12:34:41 PM

Using 1 - The VBlongDate Shows The Date As Long Date

<%

Response.write formatdatetime (TodaySdate, 1)

%>

RESULT: Monday, February 14, 2005

Using 2 - The VbshortDate Shows The Date As Short Date

<%

Response.write formatdatetime (TodaySdate, 2)

%>

RESULT: 2/14/2005

USING 3 - The VBlongTime Format Shows The Time As long time.

<%

Response.write formatdatetime (TodaySdate, 3)

%>

Result: 12:34:41 PM

USING 4 - The VBShortTime Format Creates The Current Time in 24 Format (HH: mm)

<%

Response.write formatdatetime (TodaySdate, 4)

%>

Result: 12:34

INTERNATIONAL DATE AND TIMEYOU CAN Use the session.lcid property to change the formatting of the date and time.

For example

<% Session.lcid = 2057%> will set the date and time to UK format (DD / MM / YYYY instead of MM / DD / YYYY) Here's a list of international locales. Bear in mind that setting these will also change currency formatting .

.data {font-size: 10px}

转载请注明原文地址:https://www.9cbs.com/read-58347.html

New Post(0)