/    Sign up×
Community /Pin to ProfileBookmark

convert iso8601 to readable time

Is there a way to have javascript convert iso8601 time into 12 hour readable time format? Also, could it read –:–:– that iso8601 uses for no time, and not print anything when it finds this?

Please help!!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@nnhubbardauthorOct 16.2007 — The format for my current is: 2007-10-16 16:00:00

And if there is no time entered: 2007-10-16 --:--:--
Copy linkTweet thisAlerts:
@FangOct 17.2007 — <script type="text/javascript">
var iso='2007-10-16 16:00:00';
var time=iso.split(' ');
if(time.length<2) {
alert(time[0]+' --:--:--');
}
else {
var units=time[1].split(':');
units[0]=(units[0]>12)? (units[0]-12)+'pm' : units[0]+'am';
alert(time[0]+' '+units[0]+' '+units[1]+':'+units[2])
}
</script>
×

Success!

Help @nnhubbard spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...