How to show article author and article created date on homepage
Hi There,
Need some help here is that possible to show the Article Author name and Created Date on the Homepage "category tree"?
And when I am getting the date of an article using an API it's appearing in the following Format " 2023-06-03T19:36:12Z" How can I make them show like this "03 Jun 2023".
Thank You
-
Hi Ronit,
Due to some information that I need to clarify, I'll go ahead and create a ticket for this concern.
-
Hi Ronit
Here is the solution for your second problem which you have listed above
var date = new Date("2023-06-03T19:36:12Z");
var dateString = new Date(date.getTime() - (date.getTimezoneOffset() * 60000 ))
.toISOString()
.split("T")[0];
function dateFormater(date) {
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var day = date.getDate();
// get month from 0 to 11
var month = date.getMonth();
// conver month digit to month name
month = months[month];
var year = date.getFullYear();
// show date in two digits
if (day < 10) {
day = '0' + day;
}
// now we have day, month and year
// arrange them in the format we want
return day + ' ' + month + ' ' + year;
}
var dt = dateFormater(new Date(dateString));
console.log(dt);Let me know if it solves your issue
Thank You
Pulkit
Team Diziana
Por favor, entrar para comentar.
2 Comentários