[FEATURE] Timestamps should be customizable to use JSON date instead of epoch
See original GitHub issueSummary:
The automatic timestamps is a nice feature, but it would be nice if you could use another format such as JSON dates.
Suggestion for an extension to the options to allow for custom formatting:
{
timestamps: {
createdAt: 'createdTime',
updatedAt: 'modifiedTime',
format: ms => new Date(ms).toJSON()
},
}
For even simpler configuration, the type of format
could be e.g. "ms" | "json" | (ms: number) => any
, so that you could use format: 'json'
Code sample:
Schema
// Code here
Model
// Code here
General
// Code here
Environment:
Operating System: Ubuntu
Operating System Version: 18.04
Node.js version (node -v
): 14.2.0
NPM version: (npm -v
): 6.14.4
Dynamoose version: 2.7.3
Other information (if applicable):
Other:
- I have read through the Dynamoose documentation before posting this issue
- I have searched through the GitHub issues (including closed issues) and pull requests to ensure this feature has not already been suggested before
- I have filled out all fields above
- I am running the latest version of Dynamoose
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:10 (5 by maintainers)
Top Results From Across the Web
What is the "right" JSON date format? - Stack Overflow
I would use a format that can be easily converted to a Date object in JavaScript, i.e. one that can be passed to...
Read more >Timestamps, Time Zones, Time Ranges, and Date Formats
The timestamp is parsed either using the default timestamp parsing settings, or a custom format that you specify, including the time zone. When...
Read more >Demystifying DateTime Manipulation in JavaScript - Toptal
Here we will explore some of the key concepts that are necessary for manipulating date and time values correctly, formats that are convenient...
Read more >Swift JSON Date Formatting - Tapadoo
The JSON date format for a Date got the value of 577814769.81546402 . This almost looks like a unix epoch timestamp, but if...
Read more >Power BI - Convert Timestamp to Datetime - YouTube
Hi everybody! Parker here. Check out this quick tip on how to convert a Unix timestamp to datetime. Hope you enjoy!Enroll in my...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same issue. I use AWS amplify to generate the data models. In my bussiness logic, I must create the custom mutations or queries, I use lambda as datasources. The amplify use ISO string for AWSDateTime. In my solution, Insteads Date, I use String and convert String to Date. I hope the dynamoose can be custom the timestamps.
@henhal Totally fair. Appreciate the discussion. Just to be clear and make sure I understand, this is primarily for viewing the data in the DynamoDB Console or other 3rd party tools, correct? Because within your application you can easily do
toJSON
as you mentioned. So that is why I was misunderstanding the use case here. It’s specifically related to viewing the raw data?