流星/ JS日期 [英] Meteor / JS Dates

查看:150
本文介绍了流星/ JS日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图在流星中制作一个分时应用程序,创建项目和添加时间条目。为什么?这是我可以想象的一个测试应用程序。

So I am trying to make a timesheeting app in meteor, creating projects and adding time entries. Why? it was all I could think of as a test app.

但是,我更习惯于处理PHP,在PHP中,我将只存储一个具有时间长度的日期字段。现在,我想知道在Meteor中处理日期最好的是什么。

But, I'm more used to dealing with PHP, in PHP I would just store a date field with a time length. Right now, I'm wondering what's the best wat to deal with dates in Meteor.

做...我做同样的事情,我存储一个被解析的字符串的日期,还是日期时间对象?你如何处理日期? (我只有3个小时进入流星)

Do… I do the same thing where I store a parsed string of the date, or is it a date time object? How would you deal with dates? (I'm only 3 hours into Meteor)

推荐答案

流星还包括 momentjs 库,这使得处理日期和时间非常容易。您将获得格式化和解析的功能。

Meteor also includes the momentjs library which makes dealing with dates and times very easy. You get function to format and parse.

存储时间的最佳方法是在Date对象中。这是因为在Mongo你会得到时间戳和GMT偏差。使时区安全。

The best way to store your time is in a Date object. This is because in Mongo you will get the timestamp and its GMT deviation. Making the time TimeZone secure.

为了操纵和显示时间,请使用momentjs。

In order to manipulate and display times, use momentjs.

这篇关于流星/ JS日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆