Results 1 to 5 of 5

Thread: PHP date and time functions

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Posts
    76,596

    Default PHP date and time functions

    Code:
    
    <html>
    
    <head>
    <title>Example #1 TDavid's Very First PHP Script ever!</title>
    </head>
    <? print(Date("l F d, Y")); ?>
    
    <body>
    </body>
    </html>

  2. #2
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    Code:
    <html>
    
    <head>
    <title>Example #3 TDavid's Very First PHP Script ever!</title>
    </head>
    <? print(Date("m/j/y")); ?>
    
    <body>
    </body>
    </html>

  3. #3
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    Code:
    <html>
    <head>
    <title>Background Colors change based on the day of the week</title>
    </head>
    <? 
    $today = date("l");
    print("$today");
    if($today == "Sunday") 
    {
    $bgcolor = "#FEF0C5";
    }
    elseif($today == "Monday")
    {
    $bgcolor = "#FFFFFF";
    } 
    elseif($today == "Tuesday") 
    {
    $bgcolor = "#FBFFC4";
    } 
    elseif($today == "Wednesday")
    {
    $bgcolor = "#FFE0DD";
    } 
    elseif($today == "Thursday")
    {
    $bgcolor = "#E6EDFF";
    } 
    elseif($today == "Friday") 
    {
    $bgcolor = "#E9FFE6";
    } 
    else 
    {
    // Since it is not any of the days above it must be Saturday
    $bgcolor = "#F0F4F1";
    }
    print("<body bgcolor=\"$bgcolor\">\n"); 
    ?>
    <br>This just changes the color of the screen based on the day of the week
    </body>
    </html>

  4. #4
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    Code:
    <html>
    <head>
    <title>Background Colors change based on the day of the week</title>
    </head>
    <? 
    $today = date("w");
    $bgcolor = array(
    "#FEF0C5", "#FFFFFF", "#FBFFC4", "#FFE0DD",
    "#E6EDFF", "#E9FFE6", "#F0F4F1"
    );
    ?>
    <body bgcolor="<?print("$bgcolor[$today]");?>">
    <br>This just changes the color of the screen based on the day of the week
    </body>
    </html>

    Last edited by sherlyk; 04-30-2014 at 08:43 AM.

  5. #5
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    Code:
    <html>
    <head>
    <title>Page last updated on month/date/year hour:min PHP Script</title>
    </head>
    <?
    $last_modified = filemtime;
    print("Last Modified ");
    print(date("m/j/y h:i", $last_modified));
    ?>
    </body>
    </html>


    Last edited by sherlyk; 04-30-2014 at 08:44 AM.

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
  •