Catch local time with JS, save to Mysql, show with PHP

Asked

Viewed 145 times

0

I’m taking the local time with Javascript in the view, and sending it to the database.

The database is storing this date and time as text.

The date and time thus arrives in the database, e.g.: Sun Nov 19 2017 07:19:39 GMT-0300 (Standard Time in Argentina), a text.

When I want to show this date and time somewhere, using PHP strtotime, and the date. The time does not appear.

I know that if the date and time came that way, ex.:

Sun Nov 19 2017 07:19:39 (without the GMT and standar time...), it would work well.

What can I do to fix this?

BS.: I’m new to programming.

1 answer

0


Leaves the date the way you want it using the functions split(), slice() and join(). Then send the form with that modified date.

Then I’d be like this:

var date = new Date();
var dateFormat = date.toString().split(' ').slice(0, 5).join(' ');
console.log(dateFormat);

Browser other questions tagged

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