I
I
Ilya2019-05-22 15:44:19
React Native
Ilya, 2019-05-22 15:44:19

How to replace a dash with a dot?

Hello . Faced such task.
There is an array:

Array [
  Object {
    "date": "2019-05-04 00:00:00",
    "dueDate": "2019-05-04 00:00:00",
    "invoiceNumber": "FV/MON/X/359",
    "overdue": false,
    "valueNoTax": 100,
    "valueToPay": 123,
    "valueWithTax": 123,
  },
  Object {
    "date": "2019-05-04 00:00:00",
    "dueDate": "2019-05-04 00:00:00",
    "invoiceNumber": "FV/MON/X/358",
    "overdue": false,
    "valueNoTax": 100,
    "valueToPay": 123,
    "valueWithTax": 123,
  },
]

It is rendered via data.map in the ListItem.
Thus: <Text> {item.date} </Text>
Is it possible to somehow replace dashes with dots in the elements: date and dueDate .
To get the output: 2019-05-04 00:00:00 => 2019.05.04 00:00:00

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pcdesign, 2019-05-22
@ynizhenie

<Text> { item.date.replace(/\-/g, '.') } </Text>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question