进入另一个时间。我想转换
<table>
<tr>
<th>Test:</th>
<th>test2:</th>
</tr>
<table>
答案 0 :(得分:1)
您还应该提及“ dt_txt”变量中确切显示的格式或示例。
但是,它是一个字符串,您始终可以解析该字符串并将其拆分为不同的部分,并根据需要更新每个部分,然后再次加入它们。由于它是一个列表,因此可以在加载数据时循环执行此操作。
示例:
.form
form(enctype="multipart/form-data" action='/addprod' method='POST')
input(type="text" id='category' placeholder="Category name='category')
input(type="text" id='name' placeholder="Name" name='name')
input(type="text" id='price' placeholder="Price" name='price')
input(type="text" id='description' placeholder="Description" name='description')
input(type="file" name="images" multiple)
button(type="submit") Add
答案 1 :(得分:1)
您可以创建一个管道,该管道为日期增加一个小时,并在您的字符串中返回一个与&
串联的字符串。
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'dateAdd'
})
export class DateAddPipe implements PipeTransform {
transform(value: string | Date): string {
// if it was a string date
let oldDate = new Date(value);
// add one extra hour to the existing date
oldDate.setHours(oldDate.getHours() + 1);
// I am manually restricting you with a format like MM-DD-YYYY
// create your own format, or accept another argument and use a date library like moment to convert to your required format if you have a multi format requirement
let onlyDate = ('0' + (oldDate.getMonth() + 1)).slice(-2) + '-' + ('0' + oldDate.getDate()).slice(-2) + '-' + oldDate.getFullYear();
let onlyTime = ('0' + oldDate.getHours()).slice(-2) + ":" + ('0' + oldDate.getMinutes()).slice(-2) + ":" + ('0' + oldDate.getSeconds()).slice(-2);
return onlyDate + ' & ' + onlyTime
}
}
使用方式:
<td>{{forecastInfo.list[4].dt_txt | dateAdd}}</td>