Tengo una marca de tiempo Json que me gustaría convertir a formato de fecha y hora simple usando javascript.Convertir la marca de tiempo de Json a la fecha y hora normal en javascript
necesito la fecha y la hora en el siguiente formato: dd-mm-aaaa hr: Mn
Aquí es una fecha de ejemplo JSON del deseo de extraer la marca de tiempo: "marca de tiempo": 1326439500
{
"count": 2,
"d": [
{
"title": "Apple iPhone 4S Sale Cancelled in Beijing Amid Chaos (Design You Trust)",
"description": "Advertise here with BSA Apple cancelled its scheduled sale of iPhone 4S in one of its stores in China’s capital Beijing on January 13. Crowds outside the store in the Sanlitun district were waiting on queues overnight. There were incidents of scuffle between shoppers and the store’s security staff when shoppers, hundreds of them, were told that the sales [...]Source : Design You TrustExplore : iPhone, iPhone 4, Phone",
"link": "http://wik.io/info/US/309201303",
"timestamp": 1326439500,
"image": null,
"embed": null,
"language": null,
"user": null,
"user_image": null,
"user_link": null,
"user_id": null,
"geo": null,
"source": "wikio",
"favicon": "http://wikio.com/favicon.ico",
"type": "blogs",
"domain": "wik.io",
"id": "2388575404943858468"
},
{
"title": "Apple to halt sales of iPhone 4S in China (Fame Dubai Blog)",
"description": "SHANGHAI – Apple Inc said on Friday it will stop selling its latest iPhone in its retail stores in Beijing and Shanghai to ensure the safety of its customers and employees. Go to SourceSource : Fame Dubai BlogExplore : iPhone, iPhone 4, Phone",
"link": "http://wik.io/info/US/309198933",
"timestamp": 1326439320,
"image": null,
"embed": null,
"language": null,
"user": null,
"user_image": null,
"user_link": null,
"user_id": null,
"geo": null,
"source": "wikio",
"favicon": "http://wikio.com/favicon.ico",
"type": "blogs",
"domain": "wik.io",
"id": "16209851193593872066"
}
]
}
var date = new Fecha (indicación de fecha y hora) var hours = date.getHours(); // minutos parte de la marca de tiempo var minutes = date.getMinutes(); // segundo parte de la marca de tiempo var seconds = date.getSeconds(); // mostrará la hora en formato 10:30:23 var formattedTime = hours + ':' + minutes + ':' + seconds; –
@RajatSinghal que solo dará el tiempo ¿no? – praneybehl
Puede obtener cualquier fecha, año, desde el objeto Fecha ... en lugar de gethours use getYear ... –