Paste local time with JS, save to MySQL, show with PHP

0

I'm getting 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, eg: 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 if the date and time came this way, eg:

Sun Nov 19 2017 07:19:39 (without GMT and standard time ...) would work fine.

What could I have done to solve this?

Obs .: I'm new to programming.

    
asked by anonymous 19.11.2017 / 11:35

1 answer

0

Leave the date as you want using the split() , slice() and join() functions. Then submit the form with that modified date.

Then it would look like this:

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