zoukankan      html  css  js  c++  java
  • 【JS】时间不足10位补0方案

    (function() {
    	//创建补0函数
    	function p(s) {
    		return s < 10 ? '0' + s: s;
    	}
    
    	//创建、格式化时间函数
    	var younger_time = function(time) {
    		var time = new Date(time);
    		var year = time.getFullYear();
    		var month = time.getMonth() + 1;
    		var day = time.getDate();
    
    		//格式化时间
    		var str = year + '-' + p(month) + '-' + p(day);
    
    		//写入时间格式为 xxxx-xx-xx
    		document.getElementById("div_ID").innerHTML = str;
    	}
    
    	//服务器时间(毫秒为单位)
    	younger_time(ServerTime * 1000);
    })()
    
  • 相关阅读:
    swift
    swift
    swift
    swift
    swift
    swift
    swift
    swift
    Swift
    Nginx 访问控制
  • 原文地址:https://www.cnblogs.com/enone/p/2119476.html
Copyright © 2011-2022 走看看