μ½λ°± ν¨μλ₯Ό μ λ¬νμ¬ λ μ§ νμμ μ§μ νκΈ° μν΄ λ¬λ ₯ μκ°μ μ¬μ©νλ €κ³ νμ΅λλ€. κ·Έλ¬λ λ΄ μ½λ°±μ else 쑰건μμ μμμ΄ μ§μ λ λ μ§μ μμ΄ μ¬λ°λ₯΄μ§ μμ΅λλ€.
Jan
μ΄ Jamn
λ‘ λ°νλ¨
Mar
κ° 3amr
λ‘ λ°νλ¨
Feb
κ° F0b
λ‘ λ°νλ¨
λ΄κ° μ΄κ²μ μλͺ»νκ³ μμμ§ λͺ¨λ₯΄μ§λ§ μ€λ₯λ₯Ό λμ§μ§ μκ³ λ¬μ΄ μ΄λ κ² λμ μ€λ κ²μ΄ μ΄μνκ² λ³΄μ λλ€.
μ¬νν μ½λ
export const dateConversion = (date) => {
// Assuming date comes in 'YYYY-MM-DD` format
date = moment(date, 'YYYY-MM-DD');
return date.calendar(null, {
sameDay: '[Today]',
nextDay: '[Tomorrow]',
lastDay: '[Yesterday]',
nextWeek: 'ddd',
lastWeek: 'MMM D',
sameElse: function(now) {
if (this.isSame(now, 'year')) {
return this.format('MMM D');
} else {
// Month is incorrectly parsed here
return this.format('MMM D, YYYY');
}
}
});
}
νκ²½
2017λ
3μ 28μΌ ν 16:52:21 GMT-0400(EDT)
2017λ
3μ 28μΌ μ€ν 4μ 52λΆ 21μ΄
240
Mozilla/5.0(Macintosh, Intel Mac OS X 10_11_6) AppleWebKit/537.36(Geckoμ κ°μ KHTML) Chrome/56.0.2924.87 Safari/537.36
2.17.1
Nevermind - μλͺ»λ κ°μ λ°ννμ΅λλ€.
@dbshwang μ λ κ°μ λ¬Έμ κ° μμ΅λλ€. λΉμ μ ν΄μλλ₯Ό λ£μ΄μ£ΌμΈμ
@avi-meslati-sp μ€μ ν¬λ§·λ λ μ§κ° μλλΌ ν¬λ§·ν μ μν λ¬Έμμ΄λ§ λ°νν΄μΌ ν©λλ€. κ·Έλμ μ κ²½μ°μλ:
sameElse: function(now) {
if (this.isSame(now, 'year')) {
return this.format('MMM D');
} else {
return this.format('MMM D, YYYY');
}
}
μ€μ λ‘ μμ΄μΌν©λλ€
sameElse: function(now) {
if (this.isSame(now, 'year')) {
return 'MMM D';
} else {
return 'MMM D, YYYY';
}
}
κ°μ₯ μ μ©ν λκΈ
Nevermind - μλͺ»λ κ°μ λ°ννμ΅λλ€.