score:0

Accepted answer

you can write it in a better and cleaner way, first of all, you have not to write your module names in pascalcase, getformattedname will be a better choice! the second thing is that you are using var... avoid that.

the only thing you have to change in the format function is a format template... and as i see you have only two option (justdate and datetime) in this case, so let's write it again:

const getformatteddate = ({ dateobject, includetime }) => {
  const dateformat = includetime ? 'mm-dd-yyyy hh:mm:a' : 'mm-dd-yyyy';
  return moment.utc(dateobject).format(dateformat);
};

and about the error you got: (but am getting an error that object(...)(...).justdate is not a function) the problem is that you didn't return justdate from the formatdate function.


Related Query

More Query from same tag