From bc6d3a75321712e678fd15c31502367c4e4a0025 Mon Sep 17 00:00:00 2001 From: nacho Date: Sat, 30 Apr 2022 15:24:14 -0300 Subject: [PATCH] agrego funcion local de obtener la fecha --- helper/data.js | 8 ++++++++ pages/posts/[id].js | 7 +++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/helper/data.js b/helper/data.js index e69de29..c7e431b 100644 --- a/helper/data.js +++ b/helper/data.js @@ -0,0 +1,8 @@ +import moment from "moment"; +import "moment/locale/es"; + +export const getDateDayMonthYear = (published) => { + moment.locale("es"); + const result = moment(published).format("LL"); + return result; +}; diff --git a/pages/posts/[id].js b/pages/posts/[id].js index 2c1161f..21f6cb6 100644 --- a/pages/posts/[id].js +++ b/pages/posts/[id].js @@ -3,6 +3,7 @@ import React from "react"; import parse from "html-react-parser"; import moment from "moment"; import Image from "next/image"; +import { getDateDayMonthYear } from "../../helper/data"; export default function Posts({ post }) { return ( @@ -46,12 +47,10 @@ export default function Posts({ post }) { width="32px" height="32px" /> -
+
{" "} - Published {moment(post.published).format( - "llll" - )} by{" "} + Publicado {getDateDayMonthYear(post.published)} by{" "} {post.author.name}