Last active
August 29, 2015 14:01
-
-
Save Villanuevand/68aded797fab4308500e to your computer and use it in GitHub Desktop.
Pequeña funcion javascript para obtener un formato de fecha que comprenda el patrón: Miercoles 28 de Mayo del 2014. (día de la semana, día del mes, mes y año actual).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Pequeña funcion javascript para obtener un formato de fecha que comprenda el patrón: | |
* día de la semana, día del mes, mes y año actual. | |
* Ejemplo: Miercoles 28 de Mayo del 2014. | |
* | |
* This is a little javascript function to get the date with the follow pattern: | |
* day of the week, day of the month, month and currently year. | |
* Example: Wednsneday, May 28th of 2014. | |
*/ | |
var DateFormate = (function(window,undefined){ | |
function stringDate(){ | |
var d = new Date() | |
, dayWeek = d.getDay() | |
, day = d.getDate() | |
, month = d.getMonth() + 1 | |
, year = d.getFullYear() | |
, currentDay = null | |
; | |
switch(dayWeek){ | |
case 1: currentDay = "Lunes";break; | |
case 2: currentDay = "Martes";break; | |
case 3: currentDay = "Miércoles";break; | |
case 4: currentDay = "Jueves";break; | |
case 5: currentDay = "Viernes";break; | |
case 6: currentDay = "Sábado";break; | |
case 7: currentDay = "Domingo";break; | |
default: ; | |
} | |
switch (month) { | |
case 1: month = "Enero"; break; | |
case 2: month = "Febrero"; break; | |
case 3: month = "Marzo"; break; | |
case 4: month = "Abril"; break; | |
case 5: month = "Mayo"; break; | |
case 6: month = "Junio"; break; | |
case 7: month = "Julio"; break; | |
case 8: month = "Agosto"; break; | |
case 9: month = "Septiembre"; break; | |
case 10: month = "Octubre"; break; | |
case 11: month = "Noviembre"; break; | |
case 12: month = "Diciembre"; break; | |
default: ; | |
} | |
console.log(currentDay + " " + day + " de " + month + " de " + year + "."); | |
} | |
return { | |
//Name : function Name | |
date : stringDate | |
} | |
})(window); | |
DateFormate.date(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment