Parsing time to string results in date

Parsing time to string results in date



I'm trying to parse an excel sheet where one of the columns is time viz. 5:15PM, 7:10AM. I can store these values successfully as strings just by doing myTimeVar.toString().


5:15PM


7:10AM


myTimeVar.toString()



However, when the time value has a space in between e.g. 5:15 PM and 7:10 AM, the toString() method returns a full blown date object as string. For instance, myTimeVar.toString() prints Sat Dec 30 1899 16:15:00 GMT-0500 (Eastern Standard Time) where myTimeVar is 5:15 PM (with a space in between time and PM).


space


5:15 PM


7:10 AM


toString()


myTimeVar.toString()


Sat Dec 30 1899 16:15:00 GMT-0500 (Eastern Standard Time)


myTimeVar


5:15 PM



I even tried avoiding toString() and using String() but no success.


toString()


String()



Edit: I'm using node and convert-excel-to-json to do the parsing.



Edit 2: Node treats 5:15PM (no space) as a string but 5:15 PM (with space) as an object.


5:15PM


5:15 PM





How are you parsing it? What is the context? Node.js?
– Jared Smith
Aug 30 at 22:47






@JaredSmith, yes I'm using node and npmjs.com/package/convert-excel-to-json for parsing
– Hyperbola
Aug 30 at 22:53





If you are using the toString() method, it's obvious that the original data type is not string. So what's it?
– Cristian Traìna
Aug 30 at 22:53


toString()





@CristianTraìna Node is treating 5:15 PM as an object because of the colon. But node treats 5:15PM as string.
– Hyperbola
Aug 30 at 22:56



5:15 PM


5:15PM





Then it is a JavaScript Date object. It sounds though like your conversion library is improperly converting those values though, unless it's really supposed to be from the 1800's. I would guess it's a bug in that library, you might actually have more luck filing a github issue.
– Jared Smith
Aug 31 at 13:15







Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế