Display Date (not time) from Firestore Timestamp

前端 未结 4 1701
失恋的感觉
失恋的感觉 2021-01-16 14:56

I\'m pulling a timestamp from a Firestore database, and I only want to display the date to the user. The original timestamp is

Timestamp(seconds=1555477200,         


        
4条回答
  •  再見小時候
    2021-01-16 15:01

    You can use Date.toLocaleString() like this:

    new Date(date).toLocaleString('en-EN', { year: 'numeric', month: 'long', day: 'numeric' });
    

    const timestamp = 1555477200000;
    console.log(
       new Date(timestamp).toLocaleString('en-EN', { year: 'numeric', month: 'long', day: 'numeric' })
    );

提交回复
热议问题