ASP
  Home arrow ASP arrow Page 2 - What are Active Server Pages?
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

What are Active Server Pages?
By: Sriram K
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 226
    2004-05-24

    Table of Contents:
  • What are Active Server Pages?
  • Displaying the Current Date and Time
  • Example 1
  • Examples 2, 3 and 4
  • Cool Things You Can Do with Date, Time, and Text
  • Differences Between VBScript and JavaScript

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    What are Active Server Pages? - Displaying the Current Date and Time


    (Page 2 of 6 )

    The date and time described in this section are those that are on the server.

    Date

    To display the current date by itself in a Web page, type:

    <% =date %>

    at the point where you want it to appear. When you view the page in your browser, you should see something like this:

    Thu, Jan 23, 1997

    Note: Even though "=date" is a short script, it's actually made up of two parts. The "date" part tells the server, "Get me the date." The equal sign (=) tells the server to display the date in the Web page. If you typed just:

    <% date %>

    the server would get the current date from your system, but that's all. It wouldn't display it. There are times when it makes sense to use an ASP function without the equal sign.

    Time

    To display the current time by itself, type:

    <% =time %>

    where you want it to appear. When you view the page, you should see something like this:

    4:19:46 PM

    Now (Date and Time)

    To display the current date and time, type:

    <% =now %>

    where you want them to appear. When you view the page, you should see something like this:

    1/23/97 4:19:46 PM

    Changing the Way Date and Time are Displayed

    You can also use Active Server Pages (ASP) functions to customize the way the current date and time are displayed on your Web page. To do this, use the now function together with the following formatting functions.

    Month and Monthname

    To display the number of the current month in a Web page, type:

    <% =month(now) %>

    where you want it to appear. When you view the page in your browser, you'll see a 1 if the current month is January, 2 if it's February, and so on.

    To display the name of the current month, type:

    <% =monthname(month(now)) %>

    where you want it to appear.

    Day

    To display the day of the current month, type:

    <% =day(now) %>

    where you want it to appear. When you view the page, you'll see a number between 1 and 31.

    Year

    To display the current year, type:

    <% =year(now) %>

    where you want it to appear.

    More ASP Articles
    More By Sriram K


     

    ASP ARTICLES

    - Using MySQL with ASP
    - ADO for the Beginner
    - ADO.NET 101: Data Rendering with a DataGrid ...
    - Introducing SoftArtisans OfficeWriter 3.0 En...
    - Getting Remote Files With ASP
    - The Real Basics of Functions in ASP
    - Enhancing Readability with ASP
    - Mimicking PHP's String Formatting Functions
    - Windows Server Hacks 12, 77, and 98
    - How to Sort a Multi-Dimensional Array
    - Developing an Information Management Tool wi...
    - What are Active Server Pages?
    - Getting Remote Pages with ASP
    - FTP’ing Files with ASP
    - Apply Single-Sign-On to Your Application





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek