Date Formatting tweaks

This commit is contained in:
itzMiney committed 2024-12-30 16:23:49 +01:00
1 parent dbdfa3bafa
commit c5461e95bb
3 files changed
+12 -10

No files matched your search

+10 -7
View File
@@ -68,16 +68,19 @@ async function fetchDynamicMeta() {
const articles = response.data; const articles = response.data;
return articles.reduce((acc, article) => { return articles.reduce((acc, article) => {
const updatedAt = new Date(article.updatedAt); const createdAt = new Date(article.createdAt);
const formattedUpdatedAt = updatedAt.toLocaleDateString('de-DE', {
// Format the date directly using toLocaleDateString
const formattedCreatedAt = createdAt.toLocaleDateString('en-US', {
month: 'short',
day: '2-digit',
year: 'numeric',
hour: '2-digit', hour: '2-digit',
minute: '2-digit', minute: '2-digit',
day: '2-digit', hour12: false,
month: '2-digit', })
year: 'numeric',
});
const description = `By ${article.authorName} | Last Updated: ${formattedUpdatedAt}`; const description = `By ${article.authorName} | Article from ${formattedCreatedAt}`;
acc[`/blog/${article.slug}`] = { acc[`/blog/${article.slug}`] = {
title: article.title, title: article.title,
@@ -13,8 +13,7 @@
<div class="article-meta"> <div class="article-meta">
<p><strong>Author:</strong> {{ article.authorName}}</p> <p><strong>Author:</strong> {{ article.authorName}}</p>
<p><strong>Views:</strong> {{ article.views }}</p><br> <p><strong>Views:</strong> {{ article.views }}</p><br>
<p><strong>Created At:</strong> {{ article.createdAt | date:'medium' }}</p> <p><strong>Created At:</strong> {{ article.createdAt | date:'MMM dd, yyyy, HH:mm' }}</p>
<p><strong>Last Updated:</strong> {{ article.updatedAt | date:'medium' }}</p>
</div> </div>
</div> </div>
</div> </div>
+1 -1
View File
@@ -9,7 +9,7 @@
<div *ngFor="let article of articles" (click)="navigateToArticle(article.slug)" class="article-card"> <div *ngFor="let article of articles" (click)="navigateToArticle(article.slug)" class="article-card">
<h2>{{ (article.title | slice:0:45) + (article.title.length > 40 ? '...' : '')}}</h2> <h2>{{ (article.title | slice:0:45) + (article.title.length > 40 ? '...' : '')}}</h2>
<p>{{ (article.content | slice:0:80) + (article.content.length > 80 ? '...' : '')}}</p> <p>{{ (article.content | slice:0:80) + (article.content.length > 80 ? '...' : '')}}</p>
<p><small>By {{ article.authorName }} | {{ article.createdAt | date: 'short' }}</small></p> <p><small>By {{ article.authorName }} | {{ article.createdAt | date: 'dd/MM/yy, HH:mm' }}</small></p>
</div> </div>
</div> </div>
</div> </div>