I have my indian standard time like ,
Wed Oct 08 2014 07:40:00 GMT 0530 (India Standard Time) , which is created by javascript,
Now i want to change this format to 2014-11-10 07:40:00 to store in mysql.
how can i do this.
I hope this will help you
$date = "Wed Oct 08 2014 07:40:00";
echo date('Y-m-d h:i:s',strtotime($date));
output
2014-10-08 07:40:00
You can use the moment.js library.
var a = "Wed Oct 08 2014 07:40:00 GMT 0530 (India Standard Time)";
var b = moment(a).zone(0).format(YYYY-MM-DD HH:mm:ss);
I personally would transform your time with the time()
-function to the unix format amd with then with date()
back to your liking:
http://php.net/manual/de/function.date.php
ig: date('Ymd H:i:s',time())
would give you the momentary time in the desired format.
edit: I forget the damn '...', but I corrected that. The accepted answer ist correct and a little bit better than mine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.