View Single Post
Old 07-13-2004, 07:40 AM   #5 (permalink)
SinisterMotives
Junkie
 
Quote:
Originally posted by FaderMonkey
How do I go about using the PHP date() function? Where do I go from here?
The date() function requires a Unix time integer as its second argument, so it won't work with the MySQL timestamp. You'll need to use the MySQL UNIX_TIMESTAMP function in a query to get the timestamp into Unix format, as aoeuhtns suggests.

To answer your question - how to use the date() function: the first argument to date() is a string built up of the flags shown in the table on the manual page I linked you to. Example:

PHP Code:

<?php
  $unix_time 
mktime();
  echo 
"The Unix representation of the current date and time is " $unix_time ."<br>";
  
$human_time date("F j, Y, g:i a"$unix_time);
  echo 
$human_time;

?>
would print:

Code:
The Unix representation of the current date and time is 1089736421
July 13, 2004, 10:33 am
SinisterMotives is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46