I have created ** React Component**
class Test extends Component{
state = {
birthdate: '2020-09-20'
}
render(){
const {birthdate} = this.state;
const mdiffInDays = moment(moment()).diff(moment(birthdate), 'days');
const mdiffInWeeks = moment(moment()).diff(moment(birthdate), 'weeks');
return(
<div className="card">
<span>Today: {moment(moment()).format('DD MMM YYYY')}</span>
<span>Birthdate: {birthdate}</span>
<span>Days: {mdiffInDays}</span>
<span>Weeks: {mdiffInWeeks}</span>
</div>
)
}}
I got two question:
- Today - how instead of
23-Oct-2020
I can use"PL" region
? - Birthdate is render like: YYYY-MM-DD. How change this to
display "DD-MM-YYY"
?
I'm learning React and try to play now with dates.