Home > 类库下载 > PHP类库 > body text

Some commonly used date array sorting in PHP

高洛峰
Release: 2016-10-20 14:49:47
Original
1596 people have browsed it

In the process of developing the project, the website requires the input of some dates, such as the current year, month and day. Here are some arrays I have compiled for you that are used daily to obtain date and time.


Get the year from the beginning to the present

In the process of developing the project, the website requires the input of some dates, such as the year, month and day to date. Here are some daily uses that I have compiled for you. Array of datetimes.


Get the year from the beginning to the present

function yearArray(){
    $tody = getdate();
    $todyYear = $tody['year'];
    $startYear = 1900-1;
    $i = 1;
    for($startYear; $startYear < $todyYear; $startYear++){
        $yearArr[$i] = $startYear+1;
        $i++;
    }
    return $yearArr;
}
Copy after login


Get the array of 12 months

function monthArray(){
    $monthArr = array(1,2,3,4,5,6,7,8,9,10,11,12);
    return $monthArr;
}
Copy after login

Get all the days of a month Array

function dayArray(){
    $dayArr = array(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);
    return $dayArr;
}
Copy after login


Get the array from Monday to Sunday

function weekArr(){
    return  array(&#39;1&#39;=>&#39;星期一&#39;,&#39;2&#39;=>&#39;星期二&#39;,&#39;3&#39;=>&#39;星期三&#39;,&#39;4&#39;=>&#39;星期四&#39;,&#39;5&#39;=>&#39;星期五&#39;,&#39;6&#39;=>&#39;星期六&#39;,&#39;7&#39;=>&#39;星期日&#39;);
Copy after login


Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!