//计算时间
var
sendTime
=this
.
props
.
obj
.send_time;
console
.
log
(
sendTime
);
//当前时间
var
nowTime
=
(
new
Date
()).
valueOf
();
console
.
log
(
nowTime
);
//差值
var
date3
=
nowTime
-
sendTime
;
console
.
log
(
date3
);
//天
var
days
=
Math
.
floor
(
date3
/
(
24
*
3600
*
1000
))
//时
var
leave1
=
date3
%
(
24
*
3600
*
1000
)
var
hours
=
Math
.
floor
(
leave1
/
(
3600
*
1000
))
//分
var
leave2
=
leave1
%
(
3600
*
1000
)
var
minutes
=
Math
.
floor
(
leave2
/
(
60
*
1000
))
//秒
var
leave3
=
leave2
%
(
60
*
1000
)
var
seconds
=
Math
.
round
(
leave3
/
1000
)
var
disAndTimeText
;
if
(
days
>
0
){
var
myText
=
'600m '
+
days
+
'天前'
disAndTimeText
=
<
Text
style
=
{
styles
.
disAndTimeText
}>{
myText
}</
Text
>
}
if
(
days
==
0
&&
hours
>
0
){
var
myText
=
'600m '
+
hours
+
'小时前'
disAndTimeText
=
<
Text
style
=
{
styles
.
disAndTimeText
}>{
myText
}</
Text
>
}
if
(
days
==
0
&&
hours
==
0
&&
minutes
>
0
){
var
myText
=
'600m '
+
minutes
+
'分钟前'
disAndTimeText
=
<
Text
style
=
{
styles
.
disAndTimeText
}>{
myText
}</
Text
>
}
if
(
days
==
0
&&
hours
==
0
&&
minutes
==
0
&&
seconds
>
0
){
var
myText
=
'600m 刚刚'
disAndTimeText
=
<
Text
style
=
{
styles
.
disAndTimeText
}>{
myText
}</
Text
>
} 原文链接:https://www.f2er.com/react/306300.html