PHP/Development/getdate

Материал из Web эксперт
Версия от 07:03, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Acquiring Date Information with getdate()

<html>
<head>
<title>Acquiring date information with getdate()</title>
</head>
<body>
<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
?>
<hr>
<?
print "Today"s date: $date_array[mday]/$date_array[mon]/$date_array[year]<p>";
?>
</body>
 </html>



getdate(): Day of the month

<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
print "Today"s date: $date_array[mday]";
?>



getdate(): Day of the week

<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
print "Today"s date: $date_array[wday]";
?>



getdate(): Day of the week (name)

<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
print "Today"s date: $date_array[weekday]";
?>



getdate(): Day of year

<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
print "Today"s date: $date_array[yday]";
?>



getdate(): Hours of the day

<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
print "Today"s date: $date_array[hours]";
?>



getdate(): Minutes past the hour

<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
print "Today"s date: $date_array[minutes]";
?>



getdate(): Month of the year

<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
print "Today"s date: $date_array[mon]";
?>



getdate(): Month of the year (name)

<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
print "Today"s date: $date_array[month]";
?>



getdate(): Seconds past the minutes

<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
print "Today"s date: $date_array[seconds]";
?>



getdate(): Timestamp

<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
print "Today"s date: $date_array[0]";
?>



getdate(): Year (4 digits)

<?php
$date_array = getdate(); 
foreach ( $date_array as $key => $val ){
    print "$key = $val<br>";
}
print "Today"s date: $date_array[year]";
?>