How to show article author and article created date on homepage | Community
Skip to main content

How to show article author and article created date on homepage

  • June 4, 2023
  • 2 replies
  • 0 views

Ronit12

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 

2 replies

Darenne
  • June 6, 2023

Hi @ronit12

Due to some information that I need to clarify, I'll go ahead and create a ticket for this concern. 


Pulkit12
  • June 6, 2023

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