我正在尝试在一个Android应用程序中获取react-native中的当前日/月/年。
这就是我所做的:
currentDay: new Date(),
...
console.log('Date:'+this.state.currentDay ,);
console.log('Day: '+this.state.currentDay.getDay() , 'Month: ' + this.state.currentDay.getMonth(), 'Year :'+ this.state.currentDay.getYear());在控制台中,我有:
Date:Fri Jun 16 2017 11:27:36 GMT+0000 (GMT)
'Day: 5', 'Month: 5', 'Year :117'如您所见,getDay()、getMonth()和getYear()没有返回我想要的内容...
发布于 2017-06-16 21:45:54
您可以使用以下命令:
var today = new Date();
date=today.getDate() + "/"+ parseInt(today.getMonth()+1) +"/"+ today.getFullYear();
console.log(date);https://stackoverflow.com/questions/44590692
复制相似问题