Reputation: 11
Sorry for the silly question, but any help is greatly appreciated!
I need help getting the current datetime in TypeScipt in a particular format "2020-04-10T13:58:59.000+0000".
Let me give some context to the problem. I have an Angular 9 frontend with a Spring Boot backend along with an Oracle 11g DB. It's a simple CRUD frontend.
In java, the POJO Entity has this parameter in regards to the DateTime
@NotNull
@Column(name = "datetime")
@Temporal(TemporalType.TIMESTAMP)
private Date datetime;
So the task is to pass the a string datetime from angular in this format "2020-04-10T13:58:59.000+0000" to the Spring API
Once again, sorry if this question has been asked before or is trivial.
SOLUTION
Thank you for responses! For anyone with the same problem, here's the solution
import {formatDate} from "@angular/common";
let formatedDate = formatDate(new Date(),'yyyy-MM-ddThh:mm:ss.SSSZZZ','en-US');
console.log(formatedDate);
>> 2020-04-25T11:24:46.821+0300
Upvotes: 0
Views: 82
Reputation: 330
formatDate(date, 'yyyy-MM-ddThh:mm:ss.SSS+ZZZ')
https://angular.io/api/common/formatDate
Upvotes: 3