Finding the Current Date and Time in PHP Code

Posted by admin | Posted in PHP, Software Programs, Theory Subjects | Posted on 09-12-2009

0

Use strftime( ) or date( ) for a formatted time string

Finding the current date and time
<?php
print strftime(‘%c’);
print “\n”;
print date(‘r’);
?>
Output
Wed May 10 18:29:59 2006
Wed, 10 May 2006 18:29:59 -0400

Finding the month, day, and year
<?php
$a = getdate();
printf(‘%s %d, %d’,$a['month'],$a['mday'],$a['year']);
?>

Write a comment

You must be logged in to post a comment.