Nativebase: DatePicker : Change the format of the date picked

Created on 26 Jun 2018  路  9Comments  路  Source: GeekyAnts/NativeBase

Hi,

  • Versions

NativeBase : 2.6.1

  • Issue

I need to change the format of the date shown after picking a date. I couldn't find a prop just like format in DatePickerAndroid which allows me to change the date format I picked. Is this already implemented or yet to be implemented?

Most helpful comment

It might be helpful to add this to the docs, so people don't have to dig for this in the future.

All 9 comments

@Cassendra4 To what format you want to change?

I want both "MMM DD YYYY" and "ddd, MMM DD YYYY" formats

Related PR #2022

Added with with 2.7.1

It might be helpful to add this to the docs, so people don't have to dig for this in the future.

Hi, is there any example for formatChosenDate props ?

This is how I return a formatted date string with momentjs, which is in the users locale:
formatChosenDate={date => {return moment(date).format('L');}}

import format from 'date-fns/fp/format';
import { DatePicker as DP} from 'native-base';

const export DatePicker = props => (
  <DP
    formatChosenDate={format("MMM do, YYYY")}
    ...props
  />
);

How to use it to select only month or year

Was this page helpful?
0 / 5 - 0 ratings