VBScript Functions DatePart

posted by Scudyen date: Thursday, May 22, 2008 category: ASP

With DatePart() function in VBScript language you could take only some parts of current time and display/use in your applications. Following examples will show you and give a brief on this function.


Hours in 12 - hour system (DatePart("h",Now())-12)
Minutes with only one digit DatePart("n",Now())
Seconds with only one digit DatePart("s",Now())

You can use this function to display any time in differnt ways. Let's check it in another sample code :

<%
If Len(DatePart("n",Now()))=1 Then
  strMinute= 0 & DatePart("n",Now())
Else
   strMinute = DatePart("n",Now())
End If

If Len(DatePart("s",Now()))=1 Then
 strSeconds = 0 & DatePart("s",Now())
Else
 strSeconds = DatePart("s",Now())
End If

response.write "Local Time : " & Hour(Now) & ":" & n & ":" & s
%>

Output will be like this :

Local Time :  2:11:49

Read More

Custom Search



Gazatem Technologies Active News Manager


page counter

Listed with 411asp.net Listed with 4aspin.com