-1

I'm working on a members area in PHP and I'd like to know how can I format the registration date of my users? In my database, I created "join_date" that is in DATETIME.

To retrieve the date from the database, I do a prepared query and I take all information from the user. Then, I store the query in a variable "$user".

Here's how the date appears currently: http://prntscr.com/8ztdin

Code:

<span class="join-date">Join Date : <?= $user -> join_date; ?></span>

How I can format the current date and ensuring it to appear this way:

11 octobre 2015, 15:35 (it's French).

I'm sorry, I'm French, so it's possible there are some errors.

Uptop 14
  • 221
  • 1
  • 10

1 Answers1

0

You can achieve it by a combination of setlocale and strftime.

// Set locale to French
setlocale(LC_ALL, 'fr_FR');

// Correct formatting
echo strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978));

For more details have a look into the documentation:

Also note that setlocale is maintained per process.

jso
  • 484
  • 5
  • 13