Angular date time picker - Angular reusable UI componentThis package supports Angular 8
Simple Angular date time picker. Online doc is here, Online demo(StackBlitz) is here.This picker is responsive design, so feel free to try it in your desktops, tablets and mobile devices.
npm install ng-pick-datetime --save
@import "~ng-pick-datetime/assets/style/picker.min.css";
<link>
element in your index.html.import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { MyTestApp } from './my-test-app';
import { OwlDateTimeModule, OwlNativeDateTimeModule } from 'ng-pick-datetime';
@NgModule({
imports: [
BrowserModule,
OwlDateTimeModule,
OwlNativeDateTimeModule,
],
declarations: [ MyTestApp ],
bootstrap: [ MyTestApp ]
})
export class MyTestAppModule {}
<input [owlDateTime]="dt1" [owlDateTimeTrigger]="dt1" placeholder="Date Time">
<owl-date-time #dt1></owl-date-time>
<input [owlDateTime]="dt2" placeholder="Date Time">
<span [owlDateTimeTrigger]="dt2"><i class="fa fa-calendar"></i></span>
<owl-date-time #dt2></owl-date-time>
This picker uses angular animations to improve the user experience,therefore you need to install @angular/animations
and import BrowserAnimationsModule
to your application.
npm install @angular/animations --save
import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
//...
],
//...
})
export class YourAppModule { }
If you prefer to disable animation effect, use NoopAnimationsModule
instead.
The date-time picker was built to be date implementation agnostic.Developers need to make sure to provide the appropriate pieces for the picker to work with their chosen implementation.There are two pre-made modules, users need to import one of them or build your own one (learn more about this from here).
OwlNativeDateTimeModule
- support for native JavaScript Date objectOwlMomentDateTimeModule
- support for MomentJsowl-date-time
Name | Type | Required | Default | Description |
---|---|---|---|---|
pickerType |
both , calendar , timer |
Optional | both |
Set the type of the dateTime picker. both : show both calendar and timer, calendar : only show calendar, timer : only show timer. |
pickerMode |
popup , dialog |
Optional | popup |
The style the picker would open as. |
startView |
month , year , multi-year |
Optional | month |
The view that the calendar should start in. |
startAt |
T/null | Optional | null |
The moment to open the picker to initially. |
firstDayOfWeek |
number | Optional | 0 |
Set the first day of week. Valid value is from 0 to 6. 0: Sunday ~ 6: Saturday |
showSecondsTimer |
boolean | Optional | false |
When specify it to true, it would show a timer to configure the second's value |
hideOtherMonths |
boolean | Optional | false |
Whether to hide dates in other months at the start or end of the current month |
hour12Timer |
boolean | Optional | false |
When specify it to true, the timer would be in hour12 format mode |
stepHour |
number | Optional | 1 |
Hours to change per step. |
stepMinute |
number | Optional | 1 |
Minutes to change per step. |
stepSecond |
number | Optional | 1 |
Seconds to change per step. |
scrollStrategy |
ScrollStrategy | Optional | BlockScrollStrategy |
Define the scroll strategy when the picker is open. Learn more this from https://material.angular.io/cdk/overlay/overview#scroll-strategies. |
disabled |
boolean | Optional | false |
When specify to true, it would disable the picker. |
backdropClass |
string/string[] | Optional | null |
Custom class for the picker backdrop. |
panelClass |
string/string[] | Optional | null |
Custom class for the picker overlay panel. |
owl-date-time
Events | Parameter | Description |
---|---|---|
afterPickerOpen |
null | Callback to invoke when the picker is opened |
afterPickerClosed |
null | Callback to invoke when the picker is closed. |
yearSelected |
T | Callback to invoke when the year is selected.This doesn't imply a change on the selected date. |
monthSelected |
T | Callback to invoke when the month is selected.This doesn't imply a change on the selected date. |
input[owlDateTime]
Name | Type | Required | Default | Description |
---|---|---|---|---|
owlDateTime |
OwlDateTimeComponent<T> |
Require | null |
The date time picker that this input is associated with. |
owlDateTimeFilter |
( date: T)=>boolean |
Optional | null |
A function to filter date time. |
disabled |
boolean | Optional | false |
When specify to true, it would disable the picker's input. |
min |
<T> |
Optional | null |
The minimum valid date time. |
max |
<T> |
Optional | null |
The maximum valid date time. |
selectMode |
single , range , rangeFrom , rangeTo |
Optional | single |
Specify the picker's select mode. single : a single value allowed, range : allow users to select a range of date-time, rangeFrom : the input would only show the 'from' value and the picker could only selects 'from' value, rangeTo : the input would only show the 'to' value and the picker could only selects 'to' value. |
rangeSeparator |
string | Optional | ~ |
The character to separate the 'from' and 'to' in input value in range selectMode. |
input[owlDateTime]
Events | Parameter | Description |
---|---|---|
dateTimeChange |
source: OwlDateTimeInput, value: input value, input: the input element | Callback to invoke when change event is fired on this <input [owlDateTime]> |
dateTimeInput |
source: OwlDateTimeInput, value: input value, input: the input element | Callback to invoke when an input event is fired on this <input [owlDateTime]> . |
[owlDateTimeTrigger]
Name | Type | Required | Default | Description |
---|---|---|---|---|
owlDateTimeTrigger |
OwlDateTimeComponent<T> |
Require | null |
The date time picker that this trigger is associated with. |
disabled |
boolean | Optional | false |
When specify to true, it would disable the trigger. |
[owlDateTimeTrigger]
Name | Type | Required | Default | Description |
---|---|---|---|---|
owlDateTimeTrigger |
OwlDateTimeComponent<T> |
Require | null |
The date time picker that this trigger is associated with. |
disabled |
boolean | Optional | false |
When specify to true, it would disable the trigger. |
owl-date-time-inline
Name | Type | Required | Default | Description |
---|---|---|---|---|
pickerType |
both , calendar , timer |
Optional | both |
Set the type of the dateTime picker. both : show both calendar and timer, calendar : only show calendar, timer : only show timer. |
startView |
month , year , multi-year |
Optional | month |
The view that the calendar should start in. |
startAt |
T/null | Optional | null |
The moment to open the picker to initially. |
firstDayOfWeek |
number | Optional | 0 |
Set the first day of week. Valid value is from 0 to 6. 0: Sunday ~ 6: Saturday |
showSecondsTimer |
boolean | Optional | false |
When specify it to true, it would show a timer to configure the second's value |
hideOtherMonths |
boolean | Optional | false |
Whether to hide dates in other months at the start or end of the current month |
hour12Timer |
boolean | Optional | false |
When specify it to true, the timer would be in hour12 format mode |
stepHour |
number | Optional | 1 |
Hours to change per step. |
stepMinute |
number | Optional | 1 |
Minutes to change per step. |
stepSecond |
number | Optional | 1 |
Seconds to change per step. |
disabled |
boolean | Optional | false |
When specify to true, it would disable the picker. |
owlDateTimeFilter |
( date: T)=>boolean |
Optional | null |
A function to filter date time. |
min |
<T> |
Optional | null |
The minimum valid date time. |
max |
<T> |
Optional | null |
The maximum valid date time. |
selectMode |
single , range , rangeFrom , rangeTo |
Optional | single |
Specify the picker's select mode. single : a single value allowed, range : allow users to select a range of date-time, rangeFrom : the input would only show the 'from' value and the picker could only selects 'from' value, rangeTo : the input would only show the 'to' value and the picker could only selects 'to' value. |
Localization for different languages and formats is defined by OWL_DATE_TIME_LOCALE
and OWL_DATE_TIME_FORMATS
. You could learn more about this from here.
none
Daniel YK Pan
一、使用Date TimePicker <el-date-picker v-model="timeRange" type="datetimerange" align="right" :default-time='defaultTime' value-format="yyyy-MM
实际业务中经常会有选择对应的时间和日期,但是考虑到用户操作的不确定性,所以我们在写整个时候,会给出一个明确是时间范围限制 ,一般都是通过 picker-options 这个对象进行配置 1.限制时间间隔不能大于31天 :picker-options="pickerOptions" <el-date-picker style="width:250px"
element-plus中date-picker组件属性default-time不生效解决办法 在此之前解决这类问题,我通常会以以下两种方法解决,但是在element-plus中没有起到效果: 第一种: <el-date-picker class="form_date_picker" v-model="formData.orderTime" format="yyyy-MM-DD
相关文档 DatePicker 日期选择框 业务需求 设置两个时间选择框,一个是开始时间,一个是结束时间,两者相互制约,开始不能早于结束,结束不能小于开始 代码示例 1.html <a-form-item label="生效日期"> <date-time-picker @change="getPolicyStartTime"
Python程序可以通过多种方式处理日期和时间。 日期格式之间的转换是计算机的常见工作。 Python的时间和日历模块有助于跟踪日期和时间。 什么是Tick? 时间间隔是以秒为单位的浮点数。 特定的时间瞬间以1970年1月1日凌晨12:00(纪元)的秒数表示。 Python中有一个流行的time模块,它提供了处理时间和表示之间转换的功能。 函数time.time()以1970年1月1日凌晨12:0
C ++标准库不提供正确的日期类型。 C ++从C继承了日期和时间操作的结构和函数。要访问与日期和时间相关的函数和结构,您需要在C ++程序中包含头文件。 有四种与时间相关的类型: clock_t, time_t, size_t和tm 。 类型 - clock_t,size_t和time_t能够将系统时间和日期表示为某种整数。 结构类型tm以具有以下元素的C结构的形式保存日期和时间 - struc
1. 定义 慕课解释:Date和Time数据类型分别用于存储日期和时间格式类数据。 2. 前言 本小节中,我们将学习 SQL 种常见的日期和时间数据类型。 在很多真实业务中,我们需要存储一些日期时间数据,比如:用户生日,新闻联播播出时间等等;若是采用字符串存储,在操作的时候会颇为麻烦,为了方便用户,SQL 给我们提供了日期和时间数据类型和诸多好用的函数。 提示: 不同的 DBMS 对于日期和时间的
The insertdatetime plugin provides a toolbar control and menu item Insert date/time (under the Insert menu) that lets a user easily insert the current date and/or time into the editable area at the cu
通常在数据科学中,我们需要基于时间值的分析。 Python可以优雅地处理各种格式的日期和时间。 datetime库提供必要的方法和函数来处理以下场景。 日期时间表示 日期时间算术 日期时间比较 我们将逐一研究它们。 日期时间表示 日期及其各个部分通过使用不同的日期时间函数来表示。 此外,还有格式说明符,它们在显示日期的字母部分(如月份或工作日的名称)中起作用。 以下代码显示了今天的日期和日期的各个
描述 (Description) 您可以在内联选择器中选择值的数量。 就像日期有date, month, year和时间有hours, minutes, seconds 。 例子 (Example) 以下示例演示了在Framework7中使用Inline Picker/Date-time - <!DOCTYPE html> <html> <head> <meta name = "