@capacitor-community/date-picker

中文文档
7.1.0发布于 2025/09/12MITTypeScriptESM + CJS零依赖近 30 天下载 2.2万

Native DateTime Picker Plugin for Capacitor Apps

原始使用文档
文档目录25 节
  1. Capacitor Date Picker
  2. Maintainers
  3. Notice 🚀
  4. Installation
  5. Upgrade guide
  6. Roadmap
  7. ios
  8. android
  9. web
  10. API
  11. Config for iOS ( DatePickerOptions )
  12. Config for Android ( DatePickerOptions )
  13. Date Format
  14. iOS
  15. Android
  16. Android Theme
  17. Demo
  18. Usage
  19. Capacitor Config
  20. iOS setup
  21. Android setup
  22. Updating
  23. Example
  24. License
  25. Contributors ✨


Capacitor Date Picker

@capacitor-community/date-picker

Capacitor community plugin for native Date Picker


Maintainers

MaintainerGitHubSocial
Stewan Silvastewones@stewones
Daniel Pereiradanielprrazevedo@DandanPrr

Notice 🚀

We're starting fresh under an official org. If you were using the previous npm package capacitor-datepick, please update your package.json to @capacitor-community/date-picker. Check out changelog for more info.

Installation

Using npm:

npm install @capacitor-community/date-picker

Using yarn:

yarn add @capacitor-community/date-picker

Sync native files:

npx cap sync

Upgrade guide

from 2.* to 3.* we have some new settings. You can see in definitions file, we hava the sections ios and android. You must change your format configs to ios and android configs.

Very important!!

To maintain the consistency of the community plugins, we changed the name of the variable the plugin is in. As we are experiencing a change across the capacitor plugins import ecosystem, we think this is a good opportunity to do that

Before, to use the plugin, you needed to import like this

import '@capacitor-community/date-picker';
import { Plugins } from '@capacitor/core';
const { DatePickerPlugin } = Plugins;

Now, we not have the Plugins variable and we not register the DatePickerPlugin in Capacitor.Plugins To use this plugin.

Now, to use this plugin, you need to do this

import { DatePicker } from '@capacitor-community/date-picker';

You need to replace all of your code

You must also follow the guide for android.

Roadmap

ios

  • present
  • config
    • style
    • format
    • locale
    • date
    • mode
    • theme
    • timezone
    • min
    • max
    • doneText
    • cancelText
    • is24h
    • titleFontColor
    • titleBgColor
    • bgColor
    • fontColor
    • buttonBgColor
    • buttonFontColor
    • mergedDateAndTime

android

  • present
  • config
    • format
    • locale
    • date
    • mode
    • theme
    • timezone
    • min
    • max
    • doneText
    • cancelText
    • is24h

web

  • present
  • config
    • format
    • locale
    • mode
    • theme
    • background
    • min
    • max
    • doneText
    • cancelText
    • timezone
    • title

API

  • present(DatePickerOptions): Promise<{ value:string }>

Config for iOS (DatePickerOptions)

These options can be used through the present method and/or within capacitor.config.json

nametypedefault
formatstring"yyyy-MM-dd'T'HH:mm:ss.sssZ"
stylestringif iOS 14 "inline" else only "wheels"
localestringcurrent device
datestringcurrent date
modeDatePickerMode"dateAndTime"
themeDatePickerThemecurrent device
timezonestringcurrent device
minstringnull
maxstringnull
doneTextstring"OK"
cancelTextstring"Cancel"
is24hbooleanfalse
titleFontColorstringnull
titleBgColorstringnull
bgColorstringnull
fontColorstringnull
buttonBgColorstringnull
buttonFontColorstringnull

Config for Android (DatePickerOptions)

These options can be used through the present method and/or within capacitor.config.json

nametypedefault
formatstring"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
localestringcurrent device
datestringcurrent date
modeDatePickerMode"dateAndTime"
themeDatePickerTheme"light"
timezonestringcurrent device
minstringnull
maxstringnull
doneTextstring"OK"
cancelTextstring"Cancel"
is24hbooleanfalse

For more information check the definitions file

Date Format

For format, we defined the old config deprecated because we have a inconsistence between Android and iOS platforms

now you need define your forma config in android.format and ios.format

iOS

For format in iOS, you need to follow this documentation

Android

For format in Android, you need to follow this documentation

Android Theme

You can define your personalized themes in android via resources styles check example app

How you see in example, just define your picker theme in global assets your app and send via android.theme prop in your capacitor.config file or your options.android.theme in present call.

Demo

Usage

import { DatePicker } from '@capacitor-community/date-picker';
import type { DatePickerTheme } from '@capacitor-community/date-picker/src';
const selectedTheme: DatePickerTheme = 'light';

DatePicker.present({
  mode: 'date',
  locale: 'pt_BR',
  date: '13/07/2019',
  theme: selectedTheme,
  ios: {
    format: 'dd/MM/yyyy',
  },
  android: {
    format: 'dd/MM/yyyy',
  },
}).then(date => alert(date.value));

Capacitor Config

{
  //...
  "plugins": {
    "DatePickerPlugin": {
      "mode": "date",
      "locale": "pt_BR",
      "current": "13/07/2019",
      "format": "dd/MM/yyyy",
      "android": {
        "theme": "MyCustomeTheme"
      },
      "ios": {
        "style": "wheels"
      }
    }
  }
}

iOS setup

  • ionic start my-cap-app --capacitor
  • cd my-cap-app
  • npm install --save @capacitor-community/date-picker
  • mkdir www && touch www/index.html
  • sudo gem install cocoapods (only once)
  • npx cap add ios
  • npx cap sync ios (every time you run npm install)
  • npx cap open ios

Tip: every time you change a native code you may need to clean up the cache (Product > Clean build folder) and then run the app again.

Android setup

  • ionic start my-cap-app --capacitor
  • cd my-cap-app
  • npm install --save @capacitor-community/date-picker
  • mkdir www && touch www/index.html
  • npx cap add android
  • npx cap sync android (every time you run npm install)
  • npx cap open android

Now you should be set to go. Try to run your client using ionic cap run android --livereload --address=0.0.0.0.

Tip: every time you change a native code you may need to clean up the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again.

Updating

For existing projects you can upgrade all capacitor related packages (including this plugin) with this single command

npx npm-upgrade '*capacitor*' && npm install

Example

https://github.com/capacitor-community/date-picker/tree/master/example

License

MIT

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Stew
Stew

💻 📖
Daniel Pereira
Daniel Pereira

💻 📖 🚧
Caroline Oliva
Caroline Oliva

💻
jcesarmobile
jcesarmobile

💻
Valentin
Valentin

💻
Jordi De Pau
Jordi De Pau

⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

版本与发布记录

@capacitor-community/date-picker 共发布 15 个版本,首次发布于 2020/06/28;过去 12 个月发布了 0 个版本。

版本发布日期距今
7.1.0latest2025/09/121.2 年前
7.0.02025/03/141.7 年前
6.0.02024/05/042 年前
5.0.02023/05/183 年前
4.0.02023/03/173 年前
4.0.0-1next2023/02/253 年前

其他发布通道:beta → 0.3.0,next → 4.0.0-1。

关于 @capacitor-community/date-picker 的常见问题

@capacitor-community/date-picker 是什么?

Native DateTime Picker Plugin for Capacitor Apps

如何安装 @capacitor-community/date-picker?

在项目目录运行 npm install @capacitor-community/date-picker,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=7.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capacitor-community/date-picker 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capacitor-community/date-picker 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capacitor-community/date-picker 可以商用吗?

@capacitor-community/date-picker 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@capacitor-community/date-picker 的下载量有多少?

根据 npm 官方下载统计,@capacitor-community/date-picker 在 2026/10/09 – 2026/11/07 这 30 天内被下载 22,312 次,日均约 744 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capacitor-community/date-picker 还在维护吗?

最新版本 7.1.0 发布于 2025/09/12(1.2 年前);至今共发布 15 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/06/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。