Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report]DatePicker format #376

Open
binyet opened this issue Jul 4, 2024 · 1 comment
Open

[Bug Report]DatePicker format #376

binyet opened this issue Jul 4, 2024 · 1 comment
Labels
Bug Something isn't working

Comments

@binyet
Copy link

binyet commented Jul 4, 2024

Environment

windows / Microsoft Edge 版本 126.0.2592.81 (正式版本) (64 位) / Vue3

Reproduction link

https://run.iviewui.com/zmsVYiBL

Steps to reproduce

DatePicker 设置format为MM:dd HH:mm 后 显示时间错误

What is expected?

设置初始值“2024-07-04 00:00:00”, DatePicker显示 08-24 07:04

What is actually happening?

设置初始值“2024-07-04 00:00:00”, DatePicker显示 07-04 00:00

@dosubot dosubot bot added the Bug Something isn't working label Jul 4, 2024
Copy link

dosubot bot commented Jul 4, 2024

@binyet 你好!我是Dosu,一个能够帮助你解决bug、回答问题并成为贡献者的机器人。我会在等待人类维护者的过程中帮助你。

The DatePicker component in your Vue3 application is not formatting the date and time as "08-24 07:04" because the format prop is incorrectly set. To format the date and time correctly, you need to set the format prop to a string that specifies the desired format. For example:

<DatePicker
  v-model="dateValue"
  type="datetime"
  format="MM-DD HH:mm"
/>

In this example, dateValue should be a Date object initialized with "2024-07-04 00:00:00".

Here is a complete example:

<template>
  <DatePicker
    v-model="dateValue"
    type="datetime"
    format="MM-DD HH:mm"
  />
</template>

<script>
export default {
  data() {
    return {
      dateValue: new Date("2024-07-04T00:00:00")
    };
  }
};
</script>

This should ensure that the date and time are displayed as "08-24 07:04" in the DatePicker component. Additionally, ensure that the DatePicker component is correctly handling the format prop as a string. According to the ViewUIPlus library, the format prop should be a string, and the component should correctly parse and display the date based on this format [1][2].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant