Results 1 to 5 of 5

Thread: Format Date and Time Script in ASP

  1. #1
    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.

  2. #2
    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.

  3. #3
    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

  4. #4
    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)) %>

  5. #5
    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.

Similar Threads

  1. Replies: 2
    Last Post: 29-11-2011, 09:29 AM
  2. Replies: 8
    Last Post: 19-10-2011, 05:08 AM
  3. Date & time Conversion PST Pacific Standard Time to GMT
    By Austinage in forum Software Development
    Replies: 2
    Last Post: 30-07-2009, 05:38 PM
  4. Date and Time format in a BATCH File
    By RogerFielden in forum Software Development
    Replies: 3
    Last Post: 20-04-2009, 11:47 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,657,058.68730 seconds with 17 queries