简体   繁体   English

输入的字符串:日期转换为时间戳

[英]string from input: date convert to timestamp

i have this inputfield: 我有这个输入框:

<input type="date" id="filter_date" class="input_filter">

and got this string "2014-10-07" from this field but i don't know how to convert this into a timestamp without changing something on the inputfield... i thought about to use a datepicker but this cant be the only solution -.- i tried some crazy parsing, converting and some functions but all of them didnt work.. 并从此字段获取了此字符串“ 2014-10-07”,但我不知道如何在不更改输入字段的情况下将其转换为时间戳记...我想使用日期选择器,但这不能是唯一的解决方案-.-我尝试了一些疯狂的解析,转换和一些功能,但是所有这些都没有起作用。

so the question is how do i convert this string into a timestamp? 所以问题是如何将这个字符串转换成时间戳?

  CultureInfo provider = CultureInfo.InvariantCulture;
  var dateString = "2014-10-07";
  var format = "yyyy-MM-dd";
  var result = DateTime.ParseExact(dateString, format, provider);
<input name="input_filter" type="date" id="filter_date" class="input_filter">

尝试这个

echo $timestamp= strtotime($_POST['input_filter']);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM