Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jan 21, 2015
1 parent 507ade3 commit 3fa3912
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ var testStr = testDate.format("yyyy年MM月dd日hh小时mm分ss秒");
```


### diff
### ago
> 多少小时前、多少分钟前、多少秒前
```js
new Date(1421313395359).diff(1411430400000)
new Date(1421313395359).ago(1411430400000)
//=> "3个月前"

new Date(1421313395359).diff('1987-04-03')
new Date(1421313395359).ago('1987-04-03')
//=> "28年前"

new Date('2010-02-02').diff('1987-04-03')
new Date('2010-02-02').ago('1987-04-03')
//=> "23年前"
```
# date.js

4 changes: 2 additions & 2 deletions date.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
return format;
}
/**
* [diff 多少小时前、多少分钟前、多少秒前]
* [ago 多少小时前、多少分钟前、多少秒前]
* @return {[type]} [string]
*/
Date.prototype.diff = function(){
Date.prototype.ago = function(){
if(!arguments.length) return '';
var arg = arguments,
now=this.getTime(),
Expand Down

0 comments on commit 3fa3912

Please sign in to comment.