简体   繁体   English

如何将日期(长类型)转换为间隔(例如:1年6个月)?

[英]How to convert Date (long type) to the interval (example: 1 year 6 months)?

Here is my question. 这是我的问题。 I want to convert long representation of my date (10024506364) to 1 year 3 months (with rounding). 我想将我的日期(10024506364)的长格式转换为1 year 3 months (四舍五入)。 Is it possible to do it with Date.js ? 是否可以使用Date.js做到这Date.js I can't find any kind of examples how to solve this task. 我找不到任何示例来解决此任务。

I would take a look at momentjs http://momentjs.com/ . 我将看看一下momentjs http://momentjs.com/

var day = moment(1318781876406);

Very simple to use and has a ton of other features. 使用非常简单,并具有大量其他功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM