함수 date2ordinaldate

1 개요[ | ]

date to ordinal date
  • test set
2005-01-01 → 2005-001
2005-01-02 → 2005-002
2005-12-31 → 2005-365
2007-01-01 → 2007-001
2007-12-30 → 2007-364
2007-12-31 → 2007-365
2008-01-01 → 2008-001
2008-12-29 → 2008-364
2008-12-31 → 2008-366
2009-01-01 → 2009-001
2009-12-31 → 2009-365
2010-01-03 → 2010-003

2 Excel[ | ]

=YEAR(A1)&"-"&TEXT(A1-DATE(YEAR(A1),1,0),"000")
=TEXT(A1,"YYYY")&"-"&TEXT(A1-DATE(YEAR(A1),1,0),"000")

3 PHP[ | ]

$date = '2008-12-31';
$ordinal_date = date('Y', strtotime($date)).'-'.str_pad(date('z', strtotime($date))+1, 3, "0", STR_PAD_LEFT); 
echo $ordinal_date; // 2008-366

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}