How can the setlocale() function be used to format timestamps in a specific language in PHP?
To format timestamps in a specific language in PHP, you can use the setlocale() function to set the desired locale before using date() or strftime() functions. This will ensure that the output is formatted according to the specified language.
// Set the desired locale for formatting timestamps in a specific language
setlocale(LC_TIME, 'fr_FR.utf8'); // French language example
// Get the current date and time in the specified language
echo strftime('%A %d %B %Y %H:%M:%S');
Keywords
Related Questions
- What are the potential pitfalls of using while loops to display data from a MySQL database in PHP?
- What is the best practice for outputting decimal places as actual numbers in PHP?
- What are some best practices for maintaining a consistent layout while dynamically changing the content of news pages in PHP?