VBScript Functions DatePart
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
%>
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
- Simple XML RSS Parser
- Generating Random Number Using RND Function And Randomize Statement
- How to Refresh a web page or redirect to another page
- Custom Paging in ASP Fast And Easy
- Professional Contact Form
- Creating Access Database Connection String
- Using DateDiff function in SQL Statement
- VBScript Examples DatePart Function
- Executing Transact SQL UPDATE statement using SQLCommand
- Custom Paging results in ASPNET using A Better Way
- Using GetDate Function in an SQL Statement
- Copying Folders using File System Object
- Form to Mail Using CDO
- Sending Emails in JSP
- MySQL AB Offers its Enterprise Database Subscriptions through the New Red Hat Exchange
- Easy Download Manager Free Version
- ASP Chat Box
- Writing Form Data to Text Files
- Paging Records in JSP
- What is Ecommerce and the Importance of Ecommerce
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Simple XML RSS Parser
- Counting records in PHP mySQL
- ActiveNews Manager Freeware News Exchange Software
- How to write and use a JavaBean My frst java bean
- Paging Results in PHP
- Free User Registration Form
- A-timesaver-control-GridView
- ASPNET Web Counter Free Open Source Code
- Easy Download Manager Free Version
- ASP Chat Box
- Writing Form Data to Text Files
- Paging Records in JSP
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Simple XML RSS Parser
- ActiveNews Manager Freeware News Exchange Software
- Counting records in PHP mySQL
- How to write and use a JavaBean My frst java bean
- Paging Results in PHP
- Free User Registration Form
- A-timesaver-control-GridView
- ASPNET Web Counter Free Open Source Code
- Comparing Dates