ignite-jhipster
Version:
A React Native boilerplate for JHipster apps.
16 lines (15 loc) • 498 B
JavaScript
export const jsDateToLocalDate = (date) => {
if (!date || !date.getMonth) {
return ''
}
return ('0' + (date.getMonth() + 1).toString()).substr(-2) + '/' + ('0' + date.getDate().toString()).substr(-2) + '/' + (date.getFullYear().toString()).substr(2)
}
export const localDateToJsDate = (localDate) => {
const split = localDate.split('-')
const year = split[0]
const month = split[1] - 1
const day = split[2]
const d = new Date()
d.setUTCFullYear(year, month, day)
return d
}