Time in Mysql and PHP

Asked

Viewed 336 times

2

Next people are with a current_date in the MySQL and return me the day of registration only in the format of the bank : 2017-01-06.

How do I leave it in format: Friday, 06 de January, 2017.

To display my data in the database I use

<?php echo $row->data; ?>

Show her in Portuguese I did but with the echo strftime("%A, %d of %B of %Y", strtotime($date)); He returns to me all the dates on December 31, 1969. If I put echo strftime("%A, %d of %B of %Y", strtotime('Today')); They all get today.

1 answer

1

Try it this way:

setlocale(LC_TIME, 'portuguese');
date_default_timezone_set('America/Sao_Paulo');

$date = $row->data;
echo strftime("%A, %d de %B de %Y", strtotime($date));
  • Already yes, it gives me all with a same date, the format even works but the date comes December 31, 1969.

  • If I put with strtotime('Today')); It gives me the current date but the issue is that I do not want to display today in every post I want to display the date on which it was posted. I tested in an old post and gave me today’s date.

  • Usually when the date comes 12/31/1969 is why there was a failure to convert the date. How is the date coming from your bank? Is it a DATE field? (yyyy/mm/dd)

  • Yes it is in a field in SQL but in sending to the database it takes the exact day through a current_date

Browser other questions tagged

You are not signed in. Login or sign up in order to post.