需要获取信息,EndDate是否过期(EndDate为行,其中键入有关购买用户溢价日期的信息)connectuser2db();
$bile_sql = "SELECT EndDate FROM tbl_rfuser WHERE Serial = '" . $userdata['serial'] . "'";
if (!($bile_result = mssql_query($bile_sql))) {
echo "Unable to select query the Billing table";
exit;
}
$bilel = mssql_fetch_array($bile_result);
$userdata['Enddate'] = $bilel['EndDate'];
$t_logd = $bilel['EndDate'];
echo $t_logd;
结果类似Jul 14 2020 02:3600:000PM(如果EndDate为smalldatetime数据类型)$time = date("Y-m-d H:i:s");
echo $time;
结果如2020-07-15 14:51:21
如果我在此行中使用$time,它会将enddate更新为当前时间:$t_login = $userdata["lastlogintime"]; // last user login in game (from mssql) Jul 15 2020 02:36:00:000PM
$t_logd = $bilel['EndDate']; // Premium EndDate (from mssql) Jul 14 2020 02:36:00:000PM
$time = date("Y-m-d H:i:s"); // current time (from php) like 2020-07-15 14:51:21
if( $t_logd <= $t_login )
{ connectuser2db();
$user_update = "UPDATE tbl_rfuser SET EndDate='" . $time . "' WHERE Serial= '" . $userdata["serial"] . "'";
mssql_query($user_update); }
它成功地比较“LastLogin”和“EndDate”,如果帐户是新的或者用户上次在EndDate过期之前在线--将EndDate更改为当前时间,则成功地从$time取值。 但如果用户在结束日期之后登录,则不起作用
需要此比较:if( $t_logd <= $t_login ) //working now
更改为比较类似:if( $t_logd <= $time ) // not working now
请帮助我如何从mssql获取当前时间或改变$time的东西,可以比较? 尝试了strtotime,但无法执行(sql server会在毫秒内检查它,但我的php已旧,无法使用日期(“y-m-d h:i:s:v”)格式)