Home > php教程 > php手册 > body text

php根据日期或时间戳获取干支纪年,生肖和星座信息的方法

WBOY
Release: 2016-06-21 08:48:54
Original
1434 people have browsed it

分享一个利用php根据日期或时间戳获取相应的干支纪年,生肖和星座信息的函数方法,具体函数代码以及使用方法如下:

/**
判断干支、生肖和星座
*/
function birthext($birth){
    if(strstr($birth,'-')===false&&strlen($birth)!==8){
        $birth=date("Y-m-d",$birth);
    }
    if(strlen($birth)===8){
        if(eregi('([0-9]{4})([0-9]{2})([0-9]{2})$',$birth,$bir))
        $birth="{$bir[1]}-{$bir[2]}-{$bir[3]}";
    }
    if(strlen($birth)=$zone[0](100*$m+$d)=$zone[$i]&&(100*$m+$d)
<p><font face="Courier New">使用实例如下:</font></p>
<pre title="code">
<?php header("Content-Type:text/html;charset=utf-8");
echo '<pre class="brush:php;toolbar:false">';//http://www.Alixixi.com/php-function/868.html
$arr=birthext('1373287361'); //时间戳
print_r($arr);
$arr=birthext('2013-07-08');
print_r($arr);
$arr=birthext('20130708');
print_r($arr);
Copy after login

打印结果如下:

Array
(
    [xz] => 巨蟹座
    [gz] => 癸巳
    [sx] => 蛇
)
Array
(
    [xz] => 巨蟹座
    [gz] => 癸巳
    [sx] => 蛇
)
Array
(
    [xz] => 巨蟹座
    [gz] => 癸巳
    [sx] => 蛇
)

另外如果需要获取更详细的信息可参照本站文章:

php阳历转阴历(农历),阴历转阳历的方法



Related labels:
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!