/    Sign up×
Community /Pin to ProfileBookmark

hello,

i have a date in this format:

var _strDate = “Fri Jan 21 17:41:10 UTC+0100 2005”;

but i would convert in mm/gg/yyyy…possible?

thanks

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@CharlesJan 23.2005 — [font=monospace]<script type="text/javascript">

<!--

Date.prototype.toDateString = function () {return isNaN (this) ? 'NaN' : [this.getMonth() > 8 ? this.getMonth() + 1 : '0' + (this.getMonth() + 1), this.getDate() > 9 ? this.getDate() : '0' + this.getDate(), this.getFullYear()].join('/')}

alert (new Date ('Fri Jan 21 17:41:10 UTC+0100 2005').toDateString())

// -->

</script>[/font]
Copy linkTweet thisAlerts:
@ElegiditoJan 23.2005 — Another solution:
[code=php]
var _strDate = "Fri Jan 21 17:41:10 UTC+0100 2005";
newForm = new Date(_strDate);
newStr = ((newForm.getMonth()<10)?"0"+(newForm.getMonth()+1):newForm.getMonth())+"/"+((newForm.getDate()<10) ? "0"+newForm.getDate() : newForm.getDate())+"/"+newForm.getYear();
[/code]
Copy linkTweet thisAlerts:
@doppioauthorJan 23.2005 — fantastic...thanks 1000!!!!!
×

Success!

Help @doppio 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.19,
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,
)...