我想在PHP变量,提取时间“10:30”从stime
jQuery的字符串变量如何将jquery变量传递给php变量?
和转让价值的 “10:30” 这样的格式“10,30”
<script>
var stime = 'Sat Dec 17 2011 10:30:00 GMT+0530 (India Standard Time)';
<?php
$s = "<script>document.write(stime);</script>";
$e = "<script>document.write(etime);</script>";
$stime = substr($s,15,6);
//substr_replace(string,replacement,start,length)
$convert_stime = substr_replace($stime,", ",3,1);
?>
</script>
/**
Output Will Be
--------------
Time: 10:30
Converted Time: 10, 30
***/
有办法处理它吗?帮助我,任何建议表示赞赏。谢谢!
PHP上运行JS在客户端上运行时(在从PHP呈现页面后)服务器。您需要通过POST /通过表单获取值或使用AJAX将客户端的值“传递”到服务器端。 – Bryan 2011-12-19 06:51:08
顺便说一句:没有必要这样做,你可以转换时间和操纵JavaScript中的字符串。 – 2011-12-19 07:10:34