Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <form action="#" method="post">
    <label for="fecha_inicial">Fecha inicial (YYYY-MM-DD)</label>
    <input type="text" id="fecha_inicial" value="" />
    <label for="fecha_inicial">Fecha inicial (YYYY-MM-DD)</label>
    <input type="text" id="fecha_final" value="" />
    <input type="button" id="calcula" value="Calcular segundos" /> 
  <div id="consola">Segundos</div>


                input { padding: 5px; font-size: 13pt; }
#consola { padding: 5px; background: #EEE; }


                $( "#calcula" ).click(function() {
  if ( $("#fecha_inicial").val()!="" && $("#fecha_final").val()!="" ){
    // Capturamos valores de los campos
    var tiempo1tmp= $("#fecha_inicial").val();
    var tiempo2tmp= $("#fecha_final").val();
    // Separamos la fecha por el guión
    var tiempo1split= tiempo1tmp.split('-');
    var tiempo2split= tiempo2tmp.split('-');
    // Creamos las fechas 
    var tiempo1 = new Date(tiempo1split[0], tiempo1split[1], tiempo1split[2], 0, 0, 0, 0)
    var tiempo2 = new Date(tiempo2split[0], tiempo2split[1], tiempo2split[2], 0, 0, 0, 0)
    var dif = tiempo1.getTime() - tiempo2.getTime()

    var Segundos_de_T1_a_T2 = dif / 1000;
    var Segundos_entre_fechas = Math.abs(Segundos_de_T1_a_T2);
    $("#consola").html("Segundos: "+ Segundos_entre_fechas);
  } else {
      $("#consola").html("Debe rellenar los campos con fechas");