PHP/Development/getdate — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 10:37, 26 мая 2010

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]";
?>