unixtojd()是PHP中的內置函數,可將unix時間戳轉換為儒略日計數。 UNIX時間戳是一種跟蹤時間(以秒為單位)的方式。此計數從1970年1月1日UTC的Unix Epoch開始。因此,UNIX時間戳隻是特定日期和Unix紀元之間的秒數。
用法:
unixtojd( $unix )
參數:該函數接受如上所示的單個參數,該參數是可選的。 $unix指定將unix時間戳轉換為儒略日計數。
返回值:該函數返回作為參數傳遞的unix時間戳,該時間戳轉換為Julian day Integer。如果未傳遞任何參數,則返回當前的儒略日整數。我們可以使用jdtogregorian()函數將儒略日整數轉換為公曆日期,以了解確切日期。
例子:
Input : $unix = 1524909427 Output : 2458237 Explanation: The Gregorian date is 4/28/2018 of the given unix timestamp Input : $unix = 5677896 Output : 2440653 Explanation: The Gregorian date is 3/7/1970 of the given unix timestamp
注意:該函數隻能使用儒略日整數,直到公曆日期1/19/2038,因為在該日期Unix時間戳由於32位溢出而停止工作。
以下示例程序旨在說明unixtojd()函數。
程序1:下麵的程序演示了不傳遞任何參數時函數的用法。
<?php 
// PHP program to demonstrate the use of unixtojd()  
// function when no parameter is passed  
  
// takes the current date as unix timestamp  
$jd = unixtojd(); 
  
// prints the julian Day integer 
echo "The Julian Day integer is ", ($jd), "\n";  
  
// prints the corresponding Gregorian date  
echo "The Gregorian date is ", jdtogregorian($jd); 
?>輸出:
The Julian Day integer is 2458237 The Gregorian date is 4/28/2018
程序2:下麵的程序演示了傳遞參數時函數的使用。
<?php 
// PHP program to demonstrate the use of unixtojd()  
// function when parameter is passed  
  
// takes a unix timestamp in parameter 
$jd = unixtojd(5677896); 
  
// prints the julian Day integer 
echo "The Julian Day integer is ", ($jd), "\n";  
  
// prints the corresponding Gregorian date  
echo "The Gregorian date is ", jdtogregorian($jd); 
?>輸出:
The Julian Day integer is 2440653 The Gregorian date is 3/7/1970
參考: http://php.net/manual/en/function.unixtojd.php
相關用法
- p5.js nfs()用法及代碼示例
 - p5.js nfp()用法及代碼示例
 - d3.js d3.hcl()用法及代碼示例
 - PHP sin( )用法及代碼示例
 - p5.js nfc()用法及代碼示例
 - PHP cos( )用法及代碼示例
 - PHP tan( )用法及代碼示例
 - p5.js nf()用法及代碼示例
 - PHP exp()用法及代碼示例
 - PHP pow( )用法及代碼示例
 - d3.js d3.map.set()用法及代碼示例
 - CSS var()用法及代碼示例
 
注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 PHP | unixtojd() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
