$t=1637544;

$d=Sec2Time($t);

$d为  0年18天 22小时52分24秒

//将秒数转换为时间(年、天、小时、分、秒)

function Sec2Time($time){
if(is_numeric($time)){
$value = array(
"years" => 0, "days" => 0, "hours" => 0,
"minutes" => 0, "seconds" => 0,
);
if($time >= 31556926){
$value["years"] = floor($time/31556926);
$time = ($time%31556926);
}
if($time >= 86400){
$value["days"] = floor($time/86400);
$time = ($time%86400);
}
if($time >= 3600){
$value["hours"] = floor($time/3600);
$time = ($time%3600);
}
if($time >= 60){
$value["minutes"] = floor($time/60);
$time = ($time%60);
}
$value["seconds"] = floor($time);
//return (array) $value;
$t=$value["years"] ."年". $value["days"] ."天"." ". $value["hours"] ."小时". $value["minutes"] ."分".$value["seconds"]."秒";
Return $t; }else{
return (bool) FALSE;
}
}

php 将秒数转换为时间(年、天、小时、分、秒)的更多相关文章

  1. javascript将分,秒,毫秒转换为xx天xx小时xx秒(任何语言通用,最通俗易懂)

    // 传入参数为总分钟数,如果为秒数,毫秒数,需要对 // 此处得到总秒数 注释部分的代码调整下. function toDateDMS(minutes){ // 将分钟转换为 天,时,分,秒 if( ...

  2. JS计算两个日期时间差,天 小时 分 秒格式

    function diffTime(startDate,endDate) { startDate= new Date(startDate); endDate = new Date(endDate); ...

  3. Oracle绝对秒数转换为时间戳

    一般Oracle得到的时间格式为: 1970-01-05 01:23:56.297 为了计算两个时间的差值: 1970-01-05 01:23:56.297 与 1970-01-05 01:24:57 ...

  4. js把秒数转换为HH:MM:SS及时分秒格式

    /** * 转为HH:MM:SS * @param second * @returns {string} * @private */ var _showTime = function (second) ...

  5. SimpleDateFormat将月/日/年 时分秒转换为年-月-日 时:分:秒

    String expirTime = ”12 / 27 / 2018 12: 00: 00 AM”;SimpleDateFormat in = new SimpleDateFormat("M ...

  6. C# 秒数转日期_由秒数得到日期几天几小时_当前日期时间,转换为秒

    ///<summary> ///由秒数得到日期几天几小时... ///</summary ///<param name="t">秒数</para ...

  7. mktime(将时间结构数据转换成经过的秒数)

    mktime(将时间结构数据转换成经过的秒数)表头文件#include<time.h>定义函数time_t mktime(strcut tm * timeptr);函数说明mktime() ...

  8. php计算两个时间相差的天数、小时数、分钟数、秒数

    $startdate="2011-3-15 11:50:00";//开始时间 $enddate="2012-12-12 12:12:12";//结束时间 $da ...

  9. Go语言练习---判断闰年以及根据现在的秒数求现在的年月日

    package main import ( "fmt" "math" "time" ) /* @闰年判断 ·封装一个函数判断某一个年份是不是 ...

随机推荐

  1. 浅谈压缩感知(七):常见测量矩阵的MATLAB实现

    1.随机高斯测量矩阵 function [ Phi ] = GaussMtx( M,N ) %GaussMtx Summary of this function goes here % Generat ...

  2. 在CentOS 7上安装Nginx服务器

    下面我就我在CentOS上安装Nginx经验做简单的记录,以备后查. 1.下载nginx-release包 以CentOS 7为例,下载nginx软件包:http://nginx.org/packag ...

  3. MySql安装完成后设置远程访问的角本

    一.方法: 登陆安装Mysql的机器的Mysql, 执行: GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password001!' ...

  4. python 3使用binascii方法的报错解决

    环境是python 3 问题: 使用binascii方法一直出现报错TypeError: a bytes-like object is required, not 'str' #coding: utf ...

  5. mint 设置无线 AP

    所需软件: sudo apt-get install hostapd 1. 创建 hostapd 的 configure 文件 新建 hostapd.conf 文件,存放位置任意,与后面修改的路径一致 ...

  6. java中经常使用的快捷键

    Eclipse(MyEclipse) 经常使用快捷键Eclipse 的编辑功能很强大.掌握了 Eclipse 快捷键功能,能够大大提高开发效率. Eclipse中有例如以下一些和编辑相关的快捷键.1. ...

  7. Oracle 中包(Package)

    一.什么要使用包?        在一个大型项目中,可能有很多模块,而每个模块又有自己的过程.函数等.而这些过程.函数默认是放在一起的(如在PL/SQL中,过程默认都是放在一起 的,即Procedur ...

  8. Echarts学习记录——如何给x轴文字标签添加事件

    Echarts学习记录——如何给x轴文字标签添加事件 关键属性 axisLabel下属性clickable:true 并给图表添加单击事件 根据返回值判断点击的是哪里 感觉自己的方法有点变扭,有更好办 ...

  9. Xamarin.Android之ListView和Adapter

    一.前言 如今不管任何应用都能够看到列表的存在,而本章我们将学习如何使用Xamarin去实现它,以及如何使用适配器和自定义适配器(本文中的适配器的主要内容就是将原始的数据转换成了能够供列表控件显示的项 ...

  10. SpringBoot配置RestTemplate的代理和超时时间

    application.properties: #代理设置 proxy.enabled=false proxy.host=192.168.18.233 proxy.port=8888 #REST超时配 ...