Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Format Date and Time Script in ASP

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 10-02-2010
Member
 
Join Date: Aug 2006
Posts: 221
Format Date and Time Script in ASP
  

Hi friends,
I want to change the formats of the date and time in ASP. Since I have recently started I don't know much about the ASP. I have done that changes but in Java. Anyone out there can tell me what are the Formats of Date and Time Script in ASP..?? Please guide me about the functions that are used for the same..!! Need help as earlier as possible.!!

__________________
AMD Sempron 2800+ @ 2Ghz
Asus A7V8X-LA
120Gb Seagate barracuda 7200Rpm Ultra-ATA 100
Elixir 512mb DDR Pc3200 (Soon 1Gb)
Club 3D Radeon 9600 256Mb
Lite-On Cd & Dvd writer combo
IDE-Dvd drive
400w Psu
Windows Xp Pro Sp2
Advent Wireless Mouse & Keyboard.
Reply With Quote
  #2  
Old 10-02-2010
Member
 
Join Date: Mar 2008
Posts: 672
Re: Format Date and Time Script in ASP

If you want to check the Date or Time in ASP, you can use the FormatDateTime(). The inbuild function called FormatDateTime() is very useful for ASP. For getting the current date and time in ASP, you can use the now() function. You can use the code as mentioned below :
Code:
<% 
dim todaysDate
 todaysDate=now()
 %>
By doing this you will get the Current Date and Time.
Reply With Quote
  #3  
Old 10-02-2010
Member
 
Join Date: Nov 2008
Posts: 1,192
Re: Format Date and Time Script in ASP

I have provided you with some format of Date, just have a look on that :
If you want to check today's date then you can use the todaysDate :
Code:
<% 
Response.write todaysDate
%>
The output of the above would be :
Code:
RESULT: 2/10/2010 2:09:59 AM
If you want to display the date as long date then use the following code :
Code:
<% 
Response.write FormatDateTime(todaysDate,1)
%>
The output for the above code would be :
Code:
RESULT: Wednesday, February 10, 2010
Reply With Quote
  #4  
Old 10-02-2010
Member
 
Join Date: Nov 2008
Posts: 996
Re: Format Date and Time Script in ASP

I have tried to give some more examples for checking the weekdays. You can use the following commands for the same :
Code:
<% = weekday(now) %>
The above command will show the day in week by its number.
If you want to show a name of a day in a week, use the below command :
Code:
<% = weekdayname(weekday(now)) %>
If you want to check the number of the month in a year, then type the following command :
Code:
<% = month(now) %>
For showing the name of the month you can use :
Code:
<% = monthname(month(now)) %>
Reply With Quote
  #5  
Old 10-02-2010
Member
 
Join Date: Aug 2006
Posts: 227
Re: Format Date and Time Script in ASP

You can also auto-update the year in ASP. I have provided with a script that can auto-update the year displayed :
Code:
<%
Function CorrectCopyrightYear (CreationYear)
If Year(Now) > CreationYear Then
CorrectCopyrightYear = CreationYear & "-" & Year(Now)
Else
CorrectCopyrightYear = CreationYear
End If
End Function
%>
Hope that you find this useful.
__________________
I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Format Date and Time Script in ASP"
Thread Thread Starter Forum Replies Last Post
error message: cant login This computer date/time is not synchornize with the date/time of network fazalhassan Networking & Security 2 29-11-2011 08:29 AM
Date and Time widget does not keep time correctly in Motorola Defy Sanat Portable Devices 8 19-10-2011 05:08 AM
Date & time Conversion PST Pacific Standard Time to GMT Austinage Software Development 2 30-07-2009 05:38 PM
Date and Time format in a BATCH File RogerFielden Software Development 3 20-04-2009 11:47 AM


All times are GMT +5.5. The time now is 02:06 PM.