Skip to content

Instantly share code, notes, and snippets.

@bespr
Created March 30, 2020 11:36
Show Gist options
  • Save bespr/a8efb2fcae575e06f014e4232e0bbe71 to your computer and use it in GitHub Desktop.
Save bespr/a8efb2fcae575e06f014e4232e0bbe71 to your computer and use it in GitHub Desktop.
javascript:(function(){ var text = ""; var activeEl = document.activeElement; var activeElTagName = activeEl ? activeEl.tagName.toLowerCase() : null; if ( (activeElTagName == "textarea") || (activeElTagName == "input" && /^(?:text|search|password|tel|url)$/i.test(activeEl.type)) && (typeof activeEl.selectionStart == "number") ) { text = activeEl.value.slice(activeEl.selectionStart, activeEl.selectionEnd); } else if (window.getSelection) { text = window.getSelection().toString(); } var timestamp = parseInt(text) * 1000; var d = new Date(); d.setTime(timestamp); alert(d.toString()); }());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment