MK01111000
MK01111000

Reputation: 822

How do I display a formatted date in Vue while populating input boxes

Is it possible when populating input boxes with Vue from an object to display a formatted date in the input box?

This is how the input box is populated with :vue

<input type="text" id="Example" :value="v.date" spellcheck="false">

v.date is the date as stored in the object Timestamp(seconds=1576436040, nanoseconds=0)

In the end I would like the input box to display the date as 15 December 2019 19:54

Upvotes: 0

Views: 86

Answers (1)

Renaud Tarnec
Renaud Tarnec

Reputation: 83048

You should use the toDate() method of the Timestamp.

You can either call this method when you populate the v.date value (after fetching the data from Firestore I guess) or by doing

<input type="text" id="Example" :value="v.date.toDate()" spellcheck="false">

Upvotes: 1

Related Questions