When I insert time (13:21) as a “time” in MSSQL Server it correctly instert into data base as a 13:21:56.1900000 but when I retrieve time using react it shown with 1970-01-01T13:21:56.190Z like wise. But I only want the time as what I input using the forum. (HH:MM:SS). So, Can I know how to remove those characters which place on front and back?
This is the table which I retrieve data from my data base.
this is how data shown in database (MSSQL Server)
I used this but as a output it gave a different time.
Input → (‘1970-01-01T13:21:56.190Z’)
@camperextraordinaire How to fix this issue?
Another approach is to split the string using
T as the delimiter to get the following array:
The take the second element of this array and split it using
. as the delimiter to get the following array:
Then, the first element of this array is your time.
The other way should have worked if your local timezone was the same as the timezone of the MSSQL server.
That being said, you might try the following so the timezone difference would not matter:
const date = new Date('1970-01-01T13:21:56Z');
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.