Format date as 'g:i:s a' in PHP

Description

The following code shows how to format date as 'g:i:s a'.

Example


/* w w w.  j a v a 2  s.c om*/
<!DOCTYPE html>
<html>
  <body>
    <h1>
    <?php
    $currentTime = date( "g:i:s a" );
    echo "Hello, world! The current time is $currentTime";
    ?>
    </h1>
  </body>
</html>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone