Home > front end >  Front end when how to split second transformation with a timestamp, thank you for your bosses
Front end when how to split second transformation with a timestamp, thank you for your bosses

Time:05-14

'22:17:33', when the background to the string, how to translate into Number type timestamp, and front-end display when it is too minutes format conversion, again thank you bosses give directions,

CodePudding user response:

New Date ()

CodePudding user response:

Let val='22:17:33'

Var valDeta=new Date (val).

CodePudding user response:

Reference
//minutes when formatting date
Var time=new Date ();
The console. The log (date. GetHours ());
The console. The log (date. GetMinutes ());
The console. The log (date. GetSeconds ());

The function getTimer () {
Var time=new Date ();
Var y=date. GetFullYear ();
Var m=date getMonth () + 1;
Var d=date. GetDate ();
Var w=date. GetDay ();
Var w1=[' on Sunday, Monday, Tuesday, Wednesday, ' ', 'on Thursday, Friday,' Saturday]
Var h=date. GetHours ();
H=h & lt; 10? '0' + h: h;
Var min=date. GetMinutes ();
Min=min & lt; 10? The '0' + min: min;
Var s=date. GetSeconds ();
S=s & lt; 10? '0' + s: s;

Return 'now is:' + y + 'years' + m + + d +', '+' month 'h + + min' : '+', '+ +' s + w1 [w];
}

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Copyright statement: this article to CSDN blogger (Eason - Chan2010) of the original articles, follow BY CC 4.0 - SA the copyright agreement, reproduced and this statement, please attach the original source link
The original link: https://blog.csdn.net/m0_37064867/article/details/100803075

CodePudding user response:

 console. The log (new Date (). The getTime ()) 
The console. The log (new Date (1620870369938))

CodePudding user response:

"8:04:35" to convert the number/type of timestamp, use new Data () useless ah

CodePudding user response:

Minutes when no date, this is no way to turn a timestamp, at least,
Details refer to: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date

CodePudding user response:

Var STR="8:04:35";
Var date=new date ();
Date. SetHours (... STR. The split (', '))
Var time=date. GetTime ();

CodePudding user response:

Var STR="8:04:35";
Var date=new date ();
Var time=date. SetHours (... STR. The split (', '))

CodePudding user response:

refer to the eighth floor chenrynet response:
var STR="8:04:35";
Var date=new date ();
Var time=date. SetHours (... STR. The split (', '))


The best adding milliseconds to string
  • Related