我正在嘗試使用 php 中的 strtotime 從多個(gè)選擇框中連接日期和時(shí)間值,但是,我需要在我的 ajax 調(diào)用中使用這個(gè)轉(zhuǎn)換后的時(shí)間戳變量。編碼: <form> <select id="month"> <option value="1">January</option> </select> <select id="day"> <option value="22">22</option> </select> <select id="year"> <option value="2020">2020</option> </select> <select id="time"> <option value="12:00:00">12:00</option> </select> <button id="submitNow"></form>$("#submitNow").click(function(e){ e.preventDefault(); var timestamp = /*need to basically do strtotime($month . "-" . $day . "-" . $year . " " . $time) */ var promises = []; var promise; $.when.apply($, promises).then(function() { $.ajax({ type:'POST', url:'url/test', data:{timestamp:timestamp}, _token: '{{ csrf_token() }}', success:function(data){ window.location.href = "/library"; } }); });});所以基本上,在 PHP 中,我可以轉(zhuǎn)儲(chǔ)strtotime($month . "-" . $day . "-" . $year . " " . $time)并獲取 1-22-2020 12:00:00 的 unix 時(shí)間戳,但我需要以某種方式(在 Laravel 中)執(zhí)行此操作,以便我可以在我的 ajax 中提交時(shí)間戳 (1548158400)稱呼我能做到這一點(diǎn)的最佳方法是什么?
將在 ajax 調(diào)用中工作的 Strtotime 函數(shù)
慕桂英3389331
2021-08-27 09:55:47