Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] Change date format #940

Closed
bibicadotnet opened this issue Jul 4, 2024 · 1 comment
Closed

[HELP] Change date format #940

bibicadotnet opened this issue Jul 4, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@bibicadotnet
Copy link

bibicadotnet commented Jul 4, 2024

Currently Artalk uses the default y-m-d, example 2024-07-05

Is there any way to convert it back to d/m/y at g:i A format (for example, 05/07/2024 at 4:18 AM)?

@qwqcode qwqcode added the enhancement New feature or request label Jul 12, 2024
@qwqcode qwqcode closed this as completed Aug 29, 2024
@bibicadotnet
Copy link
Author

Yes, I just updated to Nightly Version, the configuration I use is as follows

<script>
Artalk.init({
  el:        '#Comments',
  pageKey:   '',
  pageTitle: '',
  server:    'https://comment.bibica.net',
  site:      'BIBICA.NET',
  dateFormatter: (date) => {
    // Định dạng ngày tháng
    const day = new Intl.DateTimeFormat('en-GB', { day: '2-digit' }).format(date);
    const month = new Intl.DateTimeFormat('en-GB', { month: '2-digit' }).format(date);
    const year = new Intl.DateTimeFormat('en-GB', { year: 'numeric' }).format(date);
    let time = new Intl.DateTimeFormat('en-GB', { hour: '2-digit', minute: '2-digit', hour12: true }).format(date);
    
    // Chuyển đổi 'am' và 'pm' thành 'AM' và 'PM'
    time = time.toUpperCase();
    
    return `${day}/${month}/${year} at ${time}`;
  }
});
</script>

Everything turned out exactly as I wanted it to.
2024-08-30_11-45-19.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants