I want to save my timestamp in following format with TypeORM on NestJS
Date formats should be YYYY-MM-DDTHH:MM:SS+01:00 or YYYY-MM-DDTHH:MM:SS.sss+01:00
If you use new Date() you will get the same format you mention above. You can also use the package moment,js.
Related
In my PostgreSQL database, the datetime stored as 2022-05-10 10:44:19+08 and when I get
the datetime by using the sequelize, it will give in format:: 2022-05-10T02:44:19.000Z.
So, my question is how to convert to 2022-05-10 10:44:19 ?
Thanks in advance.
There is a direct dependence on the time of your server. Therefore, depending on what you want to get, you can use different options.
Here is a dbfiddle with examples
I am trying to read some data from the SharePoint API via the older _vti_bin/client.svc endpoint
I can't seem to find what type of date format this is and how I can parse it via C#.
The timestamp being returned is:
"LastContentModifiedDate": "/Date(2022,3,18,13,12,28,990)/"
The year and month are obvious so I could parse it myself if I knew what all the values are. Is there a formal definition for this or a way to parse this reliably? Is this a DateTime or DateTimeOffset or something else?
I just get an exception when trying to deserialize to a DateTime or DateTimeOffset.
The /Date(...)/ format is Microsoft's built-in JSON date format.
You can try to parse it using the code below.You can also check out this post, which provides a lot of methods.
using System.Web.Script.Serialization;
//code
JavaScriptSerializer json_serializer = new JavaScriptSerializer();
DateTime ddate = json_serializer.Deserialize<DateTime>(#"""\/Date(1326038400000)\/""").ToLocalTime();
i have a excel file with some data , now i want to take data from this excel file and store it into mongodb same as we store data through making mongoose schema. I dont know anything about this process , i,m totally new . so can someone please suggest me a proper documentation for this or guide me where to start ... and if possible can tell me how this whole process works (Basic steps)
Iam using Nodejs express
Basic steps:
convert the excel to js object (use npm to install):
https://www.npmjs.com/package/convert-excel-to-json
.. maybe convert the result object to match mongo schema .. (just js code, change properties etc.)
save the object to db:
https://www.kompulsa.com/introduction-mongoose-storing-data-mongodb/
(in this example it will be new Bug(YOUROBJECT))
in Mongodocs, it is said that datetimes with specified "Z" timezone at the end are saved as "UTC" datetime format..
https://docs.mongodb.com/manual/reference/method/Date/
I created some sample time data in Python:
now=str((datetime.datetime.now()).isoformat())+'Z'
then=str((datetime.datetime.utcnow()+datetime.timedelta(0,one_week_in_seconds)).isoformat())+'Z'
I used datetime.now() and datetime.utcnow() and appended 'Z' on both...
this is what I get:
'now': '2018-07-10T11:06:05.512484Z',
'then': '2018-07-17T09:06:05.512484Z',
I am now using MEAN stack with Node/Express and mongoose (ODM) Driver to make my schema models in the database. When I push the data via some router middleware to my mongoDB Database, the two fields have mongoose "Date" format. However, for both fields it creates an ISODate time format...:
"now" : ISODate("2018-07-10T09:02:01.410Z"),
"then" : ISODate("2018-07-17T09:02:01.410Z"),
I think thats a bug, normally, if "Z" is specified, it should create the specified time in ISO-Format, which it is here, but as I have created the time in local-time format and appended a "Z" in the first case ("now"), the time should be saved as 'now' : ISODate("2018-07-10T11:06:05.512484Z") without modifying /
converting from local to UTC time or not?
if you want to save specific country timezone and if you are using moment then it is easy to manage
below link will help to you
Updating time offset with moment().utcOffset()
I am having weather data in grib2 format and i want to convert it into json format or csv. I know the languages PHP , node.js. Is it possible to conversion using these technologies?
Using Nodejs try this package may help you
https://www.npmjs.com/package/grib2json