js秒数转换时分秒方法】的更多相关文章

今天写一个东西的时候 发现给出的是秒数.实在找不到直接的工具去转换. 就去网上找了个转换方法(有现成的就不写了,以后再简化下代码). function formatSeconds(value) { var theTime = parseInt(value);// 秒 var theTime1 = 0;// 分 var theTime2 = 0;// 小时 // alert(theTime); if(theTime > 60) { theTime1 = parseInt(theTime/60);…
前言 通讯记录需要用到的一个方法,就是将秒转为时分秒 方法 PHP有内置的方法,直接用即可,不过这个只是24小时以内.对于通讯录来说是够用了~ 示例 $v = 30; gmdate('H:i:s', $v); //00:00:30 如果要改成XX时XX分XX秒这种格式只要转化下就可以了,我这里直接用三元嵌套了 /** * 处理时间 * * @param string $s 转化好的时间 * * @return string $ftime 处理好的时间 */ public function fti…
getTime()  返回距 1970 年 1 月 1 日之间的毫秒数 new Date(dateString) 定义 Date 对象的一种方式 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script type="text/javascript" src="js/jquery-3.1.1.min.js"></scri…
转载自:http://jingyan.baidu.com/article/375c8e19a0413925f2a229d2.html <script language="javascript"> /** * 将秒数换成时分秒格式 * 整理:www.jbxue.com */ function formatSeconds(value) { var theTime = parseInt(value);// 秒 var theTime1 = 0;// 分 var theTime2…
/** * 转换时间格式为xx小时xx分xx秒 * @param second xxxxx */ public String changeTimeFormat(String second) { Integer seconds = Integer.valueOf(second); if (seconds > 0 && seconds < 60) {//小于1分钟 return seconds + "秒"; } else if (seconds >= 60…
function secondToTimeStr(t) { if (!t) return; if (t < 60) return "00:" + ((i = t) < 10 ? "0" + i : i); if (t < 3600) return "" + ((a = parseInt(t / 60)) < 10 ? "0" + a : a) + ":" + ((i = t % 60…
function secondsToHour($seconds){ if(intval($seconds) < 60) $tt ="00时00分".sprintf("%02d",intval($seconds%60)); if(intval($seconds) >=60){ $h =sprintf("%02d",intval($seconds/60)); $s =sprintf("%02d",intval($sec…
PHP函数 1.gmdate $seconds = 174940;$hours = intval($seconds/); $time1 = $hours."小时".gmdate('i分钟s秒', $seconds); echo $time1; 2.gmstrftime $seconds = ; $hours = intval($seconds/); $time1 = $hours.":".gmstrftime('%M:%S', $seconds); echo $ti…
/** * 把秒数转换为时分秒的格式 * @param Int $times 时间,单位 秒 * @return String */ function secToTime($times){ $result = '00:00:00'; if ($times>0) { $hour = floor($times/3600); $minute = floor(($times-3600 * $hour)/60); $second = floor((($times-3600 * $hour) - 60 *…
http://yangjunwei.com/a/930.html PHP函数gmstrftime()将秒数转换成天时分秒   一个应用场景需要用到倒计时的时分秒,比如新浪微博授权有效期剩余: 7天16小时47分钟42秒…… 在PHP环境下,PHP函数 gmstrftime() 可实现将秒数转换成时分秒的转换,先看例子: define("BJTIMESTAMP" , time()); //服务器当前时间 $expires_in = '1439577160';//到期时间 $expires…