question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing time to string results in date

See original GitHub issue

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().

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).

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

More details here.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DiegoZoracKycommented, Sep 4, 2018

Yes, excel has this kinda of weird behavior. Try to copy all the values of this column to the Notepad (or other text editor), select the entire column and change its type to Text, then paste back the values from Notepad. After that, hopefully you will have all the original data as text.

0reactions
JaviPGcommented, Sep 21, 2020

Anybody found solution for convert date fields to string fields?

Currently I’m try solve it. If can i find way I’ll share it with you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Date.parse() - JavaScript - MDN Web Docs
The parse() method takes a date string (such as "2011-10-10T14:48:00" ) and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC....
Read more >
Formatting and parsing dateTimes as strings - IBM
This section gives information on how you can specify the dateTime format using a string of pattern letters.
Read more >
javascript - Parsing time to string results in date - Stack Overflow
I'm trying to parse an excel sheet where one of the columns is time viz. 5:15PM , 7:10AM . I can store these...
Read more >
DateTime.Parse Method (System) - Microsoft Learn
The Parse method tries to convert the string representation of a date and time value to its DateTime equivalent. It tries to parse...
Read more >
Parsing: date-time - clock
date_time_parse() is useful for strings like "2019-01-01 00:00:00" , where the UTC offset and full time zone name are not present in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found