LoginSignup
3

More than 5 years have passed since last update.

【AngularJS】JSONで受け取ったDateTimeの表示

Last updated at Posted at 2016-03-04

MVCでAngularJSを利用してアプリケーション作成中、
DateTime型のデータ出力でつまづいたのでメモ

【Sample.cshtml】
{{sample.Date}}
/Date(1457058672120)/

{{sample.Date | date:'yyyy/MM/dd HH:mm'}}
/Date(1457058672120)/

{{sample.Date.substring(6,sample.Date.length-2) | date:'yyyy/MM//dd HH:mm'}}
2016/03/04 11:31

JSONでのDatetimeのやりとり

/Date(ticks)/ の形式にシリアライズされていしまう。
※ticks = 1970/1/1からのミリ秒

date:'yyyy/MM//dd HH:mm'

date型に整形してくれるフィルター

str.substring(indexA[,indexB])

var str = "SampleText";
str.substring(0,3); //=Sam
str.substring(3,5)/ //=plete
str.subsring(6,str.length); //=Text

※C#の String.Substring(int startIndex, int length)とは違うので注意!!
https://msdn.microsoft.com/ja-jp/library/aka44szs(v=vs.110).aspx

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3