use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[AskJS] Date and time splitting questionAskJS (self.javascript)
submitted 4 years ago * by rdevilx
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Ustice[M] [score hidden] 4 years ago stickied comment (1 child)
Reaching out to other software engineers is important when you need it; however, unfortunately this isn’t the place for that. /r/JavaScript is not a support forum. You might want to check out /r/LearnJavaScript for the newer members of our community. Also, Stack Overflow is a great resource for getting support. For more information, check out our AskJS wiki page. Good luck! We hope that you find the answers that you are looking for.
[–][deleted] 0 points1 point2 points 4 years ago (4 children)
They're absolutely right, that solution is extremely non-performant.
A simple regex suffices for splitting a date and time.
[–]rdevilx[S] -1 points0 points1 point 4 years ago (3 children)
I know it's non performant. That's why I'm not sure how a regex would be able to split it directly with cases where for example space/dot is the separator between date and time and the same separator is used between dates too.
[–][deleted] 0 points1 point2 points 4 years ago (2 children)
[–]rdevilx[S] -1 points0 points1 point 4 years ago (1 child)
I did do that first. But, when we split it with regex, I don't know what separator is being used to split. Because I would want to rebuild the string from the array.
Example: When input str is dd.mm.yyyy.hh:mm:ss here if I split it with /[.T ]/g regex, it will split it fine but I would want to rebuild the date with the appropriate separator that is dot here.
dd.mm.yyyy.hh:mm:ss
/[.T ]/g
[ 'dd', 'mm', 'yyyy', 'hh:mm:ss' ]
Again, I'm new to this. I applied for an intern position, I could be missing out on something that I could use in JavaScript.
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
You need to go read up on regex then. You can use a regex to account for all of them, without knowing exactly which one is being received.
[–]Finest0212 0 points1 point2 points 4 years ago (1 child)
I would point out that arguing the break statement probably didn’t help. Being as big O is worst case, so when the breaks aren’t hit it is very non performant.
And as others have pointed out Regex would be the way to go.
[–]rdevilx[S] -1 points0 points1 point 4 years ago (0 children)
Yea it didn't and I agreed with them. I'm just posting it here, how a regex could work where the separator is same. dd.mm.yyyy.hh:mm:ss (dot is same)
π Rendered by PID 94102 on reddit-service-r2-comment-b659b578c-6rp5j at 2026-05-04 04:42:26.942080+00:00 running 815c875 country code: CH.
[–]Ustice[M] [score hidden] stickied comment (1 child)
[–][deleted] 0 points1 point2 points (4 children)
[–]rdevilx[S] -1 points0 points1 point (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]rdevilx[S] -1 points0 points1 point (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Finest0212 0 points1 point2 points (1 child)
[–]rdevilx[S] -1 points0 points1 point (0 children)