如何在mysql数据库中存储用户输入的时间 [英] How to store user entered time in mysql database

查看:393
本文介绍了如何在mysql数据库中存储用户输入的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要存储从角度js前端输入的时间。时间格式为

HH:MM AM / PM。



当我控制日志时间时,我得到用户输入的时间,例如



Thu Jan 01 1970 01:01:00 GMT + 0530(印度标准时间)但在我的数据库中时间价值是00:00:00



我尝试过:



Angular js

I need to store time which is entered from angular js frontend.The time format is
HH: MM AM/PM.

When I console log time I am getting user entered time like

Thu Jan 01 1970 01:01:00 GMT+0530 (India Standard Time) but in my database time value is 00:00:00

What I have tried:

Angular js

<input type="text"  ng-model="name" >




<input type="time" ng-model="booktime">





控制器





Controller

$http.post("url", {

name=name;
booktime=booktime; 
 })
    
    .then(function(response){
       console.log("Data Inserted Successfully");
           console.log(booktime);
});



Mysql

booktime coloumn数据类型是时间




Mysql
booktime coloumn datatype is Time

$data = json_decode(file_get_contents("php://input"));
<pre>$name = $data->name;




$booktime=$data->booktime; 




$sql = "INSERT INTO cust(name,booktime)VALUES ('$name','$booktime')";

推荐答案

http.post( url,{

name = name;
booktime = booktime;
})

.then( function (response){
console .log( 数据已成功插入);
console .log(booktime);
});
http.post("url", { name=name; booktime=booktime; }) .then(function(response){ console.log("Data Inserted Successfully"); console.log(booktime); });



Mysql

booktime coloumn数据类型是时间




Mysql
booktime coloumn datatype is Time


data = json_decode(file_get_contents( php:// input));
< pre>
data = json_decode(file_get_contents("php://input")); <pre>


name =


这篇关于如何在mysql数据库中存储用户输入的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆