Display time on Ssm+easyui frame form

Do the basic needs of the project, the display of time, additions, deletions and revisions, etc.
The display of the time on the table is introduced here, because the general time has to be processed before it can be displayed.
The page built by the easyui framework is used here, so the js method is used to display the timestamp.
First layout: The new and modified layout does not need to write the time field. This field can be directly acquired and assigned back to the controller when it is added directly on the controller, and then converted through the page js and displayed on the table field. .
For example, when writing a log management page, add a form to modify the page:
insert image description here

Then build a script tag below, and write the js for table loading in it

/** 载入数据 */
	$('#data-datagrid').datagrid({
    
    
		url:'list',
		rownumbers:true,
		singleSelect:false,
		pageSize:20,           
		pagination:true,
		multiSort:true,
		fitColumns:true,
		idField:'id',
	    treeField:'name',
		fit:true,
		columns:[[
			{
    
     field:'chk',checkbox:true},
			{
    
     field:'content',title:'日志内容',width:100,sortable:true},
			{
    
     field:'createTime',title:'时间',width:200,formatter:function(value,row,index){
    
    
				return format(value);
			}},
		]]
	});

At the time above, pay attention to the format, and remember to write the following function.
Then write the timestamp in it:

function add0(m){
    
    return m<10?'0'+m:m }
	function format(shijianchuo){
    
    
	//shijianchuo是整数,否则要parseInt转换
		var time = new Date(shijianchuo);
		var y = time.getFullYear();
		var m = time.getMonth()+1;
		var d = time.getDate();
		var h = time.getHours();
		var mm = time.getMinutes();
		var s = time.getSeconds();
		return y+'-'+add0(m)+'-'+add0(d)+ '-'+                                   
		return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
	}

So what is a timestamp? Timestamp refers to the total number of seconds from January 01, 1970 00:00:00 Greenwich Mean Time (January 01, 1970 08:00:00 Beijing Time) to the present. In layman's terms, a timestamp is a complete verifiable piece of data that can indicate that a piece of data already exists at a specific point in time.
Then write the code for that timestamp above.
Everything else doesn't need to be written, I mean there is no need to do anything on service, impl, controller, dao, etc. The above one is enough.
Then show the result:
insert image description here

If the time field on the load data of the above table does not have the step after the function:
insert image description here

If it is written like the above picture, it will display the time as shown below:
insert image description here

And that's not the kind of datetime we want at all, so some conversion has to be done.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324212010&siteId=291194637