Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度4格式SQL时间_Angular_Typescript - Fatal编程技术网

Angular 角度4格式SQL时间

Angular 角度4格式SQL时间,angular,typescript,Angular,Typescript,如何格式化从SQL返回的时间类型值? 例如,{{value.SundayStart}返回10:00:00 我想在没有秒的情况下显示它, 但使用Angular的日期管道: {{value.SundayStart|date:'hh:mm'}} 它不起作用 谢谢仅使用时间值的日期管道是不可能的。只需使用切片管即可: {{value.SundayStart | slice:0:5}} 这将返回10:00不能仅使用时间值的日期管道。只需使用切片管即可: {{value.SundayStart | sli

如何格式化从SQL返回的时间类型值? 例如,
{{value.SundayStart}
返回10:00:00

我想在没有秒的情况下显示它, 但使用Angular的日期管道:

{{value.SundayStart|date:'hh:mm'}}

它不起作用


谢谢

仅使用时间值的日期管道是不可能的。只需使用切片管即可:

{{value.SundayStart | slice:0:5}}

这将返回
10:00

不能仅使用时间值的日期管道。只需使用切片管即可:

{{value.SundayStart | slice:0:5}}

这将返回
10:00

一个相当脏的解决方案,尽管它可以工作。做点小工作。使用
sql
返回的
time
创建日期时间对象,然后格式化为在
HH:mm
中显示时间

export class AppComponent  {
  time =  '23:34:12';
  dateTime = new Date();

 constructor() {
   let times = this.time.split(':');
   this.dateTime.setHours(parseInt(times[0]));
   this.dateTime.setMinutes(parseInt(times[1]));
   this.dateTime.setSeconds(parseInt(times[2]));
 }
}
.html


这是一个相当肮脏的解决方案,尽管它有效。做点小工作。使用
sql
返回的
time
创建日期时间对象,然后格式化为在
HH:mm
中显示时间

export class AppComponent  {
  time =  '23:34:12';
  dateTime = new Date();

 constructor() {
   let times = this.time.split(':');
   this.dateTime.setHours(parseInt(times[0]));
   this.dateTime.setMinutes(parseInt(times[1]));
   this.dateTime.setSeconds(parseInt(times[2]));
 }
}
.html


回答得好+1。好主意!回答得好+1。好主意!