<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
</head>
<body>
See the console :)
</body>
</html>
;(function(){
if(window.moment === void 0)
return console.error("Moment.js must be loaded first");
var cdnLink = 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/';
var loaded = new Set();
var available = ['af','ar-dz','ar-kw','ar-ly','ar-ma','ar-sa','ar-tn','ar','az','be','bg','bm','bn','bo','br','bs','ca','cs','cv','cy','da','de-at','de-ch','de','dv','el','en-au','en-ca','en-gb','en-ie','en-il','en-nz','en-SG','eo','es-do','es-us','es','et','eu','fa','fi','fo','fr-ca','fr-ch','fr','fy','ga','gd','gl','gom-latn','gu','he','hi','hr','hu','hy-am','id','is','it-ch','it','ja','jv','ka','kk','km','kn','ko','ku','ky','lb','lo','lt','lv','me','mi','mk','ml','mn','mr','ms-my','ms','mt','my','nb','ne','nl-be','nl','nn','pa-in','pl','pt-br','pt','ro','ru','sd','se','si','sk','sl','sq','sr-cyrl','sr','ss','sv','sw','ta','te','tet','tg','th','tl-ph','tlh','tr','tzl','tzm-latn','tzm','ug-cn','uk','ur','uz-latn','uz','vi','x-pseudo','yo','zh-cn','zh-hk','zh-tw'];
moment.loadLocale = function(locale, callback){
if(locale.length > 10)
return; // Unexpected input
if(locale.indexOf('_') !== -1)
locale = locale.split('_');
else
locale = locale.split('-');
var found = false;
for(var i=0, n=locale.length; i<n; i++){
var temp = locale.join('-');
if(available.indexOf(temp) !== -1){
found = temp;
break;
}
locale.pop();
}
if(found !== false){
if(loaded.has(found)){
moment.locale(found);
return callback && callback(found);
}
var xhr = new XMLHttpRequest();
xhr.open("GET", cdnLink+found+'.js');
xhr.onreadystatechange = function(){
if(xhr.status === 200 && xhr.readyState === 4){
this.moment = window.moment;
loaded.add(found);
eval(xhr.responseText); // Because HTML5 doesn't execute dynamic script tag
moment.locale(found);
callback && callback(found);
}
};
xhr.send();
return;
}
callback && callback(false);
}
})();
// Example
moment.loadLocale('ja_JP', function(found){
if(found === false)
return console.error("Language not found");
console.log(moment().format('LLLL'));
});
Output
300px
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |