Mam znacznik czasu Json, który chciałbym przekonwertować na prosty format daty w javascript.Konwertuj znacznik czasu Json na normalną datę i czas w javascript
muszę datę i godzinę w następującym formacie: dd-mm-rrrr HR: MN
Oto data przykład json od życzę, aby wyodrębnić timestamp: "timestamp": 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 data = new Data (znacznik czasu) var godziny = date.getHours(); // część minut z sygnatury czasowej var minutes = date.getMinutes(); // sekunda część z sygnatury czasowej var seconds = date.getSeconds(); // wyświetla czas w formacie 10:30:23 var formattedTime = godziny + ':' + minuty + ':' + sekundy; –
@RajatSinghal, który wyda tylko tyle czasu, prawda? – praneybehl
Możesz pobrać datę, rok od obiektu Date ... zamiast gethours getYear ... –