Simple Date question here, but I can't seem to find a simple answer.
I am storing the 'negative' value of a timestamp in my database like so (they are stored as numbers, not strings):
user-1
--date: -1495255666921
user-2
--date: -1495255666341
I do this for sorting purposes, but that's a separate topic.
When it comes time to read these dates under each user, I want to get the 'positive' version of the timestamp.
I know I can toString()
the date, check for the -
character, remove it, then convert it back to a Date()
(which I then have to run through another function), but that seems inefficient when sending thousands of records back to the client.
Is there a magical way I can poof - get rid of that -
and maintain it's datatype as timestamp
programatically? Any input or recommendation is appreciated!
UPDATE - Since multiple people have mentioned, this is is the 'bigger' issue I'm dealing with and why I've chosen this sorting method