[英]React Native - Customize date format using Moment.js
I am using moment.js to get the current date, however I am having a problem about the date formatting and I don't have any idea on how to customize it since I am just new using it.我正在使用 moment.js 来获取当前日期,但是我在日期格式方面遇到了问题,而且我不知道如何自定义它,因为我只是使用它的新手。
By the way I used this.顺便说一下,我用过这个。
moment().format('LLLL');
My expected output is:我的预期输出是:
Mmmm-dd-yyyy hh:mmAM/PM (Timezone) or just like Sep-19-2020 3:00AM (GMT +8)
Is the any other way to achieve this?有没有其他方法可以实现这一目标?
moment().locale('tr').format("MMM-DD-yyyy h:mA [(GMT] Z[)]")
moment().locale('en_US').format("MMM-DD-yyyy h:mA [(GMT] Z[)]")
If you want to use locale in React Native.如果你想在 React Native 中使用语言环境。
instead反而
import moment from 'moment'
you should use this你应该用这个
import 'moment/min/moment-with-locales'
moment.locale('tr');
moment().format("MMM-DD-yyyy h:mA [(GMT] Z[)]");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.