{"id":704,"date":"2024-07-30T20:20:07","date_gmt":"2024-07-30T18:20:07","guid":{"rendered":"https:\/\/blog.sutilweb.eu\/?page_id=704"},"modified":"2024-07-30T20:20:08","modified_gmt":"2024-07-30T18:20:08","slug":"002-objeto-date","status":"publish","type":"page","link":"https:\/\/sutilweb.eu\/index.php\/lenguajes\/javascript\/javascript-practico\/06-objetos-y-funciones-del-lenguaje\/002-objeto-date\/","title":{"rendered":"002. Objeto Date"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">En este cap\u00edtulo veremos las caracter\u00edsticas del constructor <strong><em>Date<\/em><\/strong>. Veamos un ejm para ver algunas de sus caracter\u00edsticas m\u00e1s importantes.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ejm<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"es\"&gt;\n&nbsp; &lt;head&gt;\n&nbsp; &nbsp; &lt;meta charset=\"UTF-8\" \/&gt;\n&nbsp; &nbsp; &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n&nbsp; &nbsp; &lt;title&gt;Constructor Date&lt;\/title&gt;\n&nbsp; &lt;\/head&gt;\n\n&nbsp; &lt;body&gt;\n&nbsp; &nbsp; &lt;h1&gt;Constructor Date&lt;\/h1&gt;\n\n&nbsp; &nbsp; &lt;script&gt;\n&nbsp; &nbsp; &nbsp; let fecha = new Date();\n&nbsp; &nbsp; &nbsp; console.log(fecha); \/\/ Muestra todos los datos de la fecha actual\n&nbsp; &nbsp; &nbsp; console.log(fecha.getDate()); \/\/ D\u00eda del mes\n&nbsp; &nbsp; &nbsp; console.log(fecha.getDay()); \/\/ D\u00eda de la semana (de domingo a s\u00e1bado)\n&nbsp; &nbsp; &nbsp; console.log(fecha.getMonth()); \/\/ Mes (guardado en un Array)\n&nbsp; &nbsp; &nbsp; console.log(fecha.getFullYear()); \/\/ A\u00f1o actual\n&nbsp; &nbsp; &nbsp; console.log(fecha.getHours()); \/\/ Hora actual\n&nbsp; &nbsp; &nbsp; console.log(fecha.getMinutes()); \/\/ Minuto actual\n&nbsp; &nbsp; &nbsp; console.log(fecha.getSeconds()); \/\/ Segundo actual\n&nbsp; &nbsp; &nbsp; console.log(fecha.getMilliseconds()); \/\/ Milisegundo actual\n&nbsp; &nbsp; &nbsp; console.log(fecha.toString()); \/\/ Todos los datos de la fecha actual\n&nbsp; &nbsp; &nbsp; console.log(fecha.toDateString()); \/\/ S\u00f3lo la fecha\n&nbsp; &nbsp; &nbsp; console.log(fecha.toLocaleString()); \/\/ Fecha actual\n&nbsp; &nbsp; &nbsp; console.log(fecha.toLocaleDateString()); \/\/ La parte de la fecha\n&nbsp; &nbsp; &nbsp; console.log(fecha.toLocaleTimeString()); \/\/ La parte de la hora\n&nbsp; &nbsp; &nbsp; console.log(fecha.getTimezoneOffset()); \/\/ Huso horario en el que nos encontramos\n&nbsp; &nbsp; &nbsp; console.log(fecha.getUTCDate()); \/\/ Huso horario en el Meridiano de Greenwich\n&nbsp; &nbsp; &nbsp; console.log(fecha.getUTCDay()); \/\/ D\u00eda en el Meridiano de Greenwich\n&nbsp; &nbsp; &nbsp; console.log(Date.now()); \/\/ Cuantos segundos han pasado desde el 1 de enero de 1970, la famosa fecha timeStamp\n\n&nbsp; &nbsp; &nbsp; \/\/ Fecha completa de nacimiento\n&nbsp; &nbsp; &nbsp; let cumpleFran = new Date(1972, 1, 14);\n&nbsp; &nbsp; &nbsp; console.log(cumpleFran);\n&nbsp; &nbsp; &lt;\/script&gt;\n&nbsp; &lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Una librer\u00eda muy poderosa para el manejo de los tiempos es <a href=\"https:\/\/momentjs.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">moment.js<\/a>. Para saber m\u00e1s acerca del manejo de Date podemos visitar <a href=\"https:\/\/developer.mozilla.org\/es\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Date\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>MDN<\/strong><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>En este cap\u00edtulo veremos las caracter\u00edsticas del constructor Date. Veamos un ejm para ver algunas de sus caracter\u00edsticas m\u00e1s importantes.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":697,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","footnotes":""},"class_list":["post-704","page","type-page","status-publish","hentry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Sutil Web","author_link":"https:\/\/sutilweb.eu\/index.php\/author\/sutilweb\/"},"uagb_comment_info":0,"uagb_excerpt":"En este cap\u00edtulo veremos las caracter\u00edsticas del constructor Date. Veamos un ejm para ver algunas de sus caracter\u00edsticas m\u00e1s importantes.","_links":{"self":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/comments?post=704"}],"version-history":[{"count":1,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/704\/revisions"}],"predecessor-version":[{"id":705,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/704\/revisions\/705"}],"up":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/697"}],"wp:attachment":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/media?parent=704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}