我们可以使用php内置函数strtotime来格式化日期为时间戳,但是由于我的输入框没有使用日期控件,需要用户自己输入日期,为了更加对用户输入的友好,特写了一个非常基础的转时间戳方法,无论用户输入:20131122085959、2013-11-22 08:59:59、2013-11.22085959等等都可以正常格式化。 /**<br>
* 日期字符串转时间戳<br>
* Author:HongPing[hongping626@qq.com] 2013.11.22<br>
* @param string $date 时间字符串<br>
* @return unixtime<br>
*/<br>
function toUnix($date){<br>
if (empty ( $date )) {<br>
return '';<br>
}<br>
$fArr = str_split('1234567890');$dArr = str_split($date);<br>
$fmdate = '';<br>
foreach($dArr as $v){<br>
if(in_array($v,$fArr)){<br>
$fmdate.=$v;<br>
}<br>
}<br>
$year =((int)substr($fmdate,0,4));//年<br>
$month =((int)substr($fmdate,4,2));//月<br>
$day =((int)substr($fmdate,6,2));//天<br>
$hour =((int)substr($fmdate,8,2));//时<br>
$minu =((int)substr($fmdate,10,2));//分<br>
$send =((int)substr($fmdate,12,2));//秒<br>
$hour=$hour?$hour:0;$minu=$minu?$minu:0;$send=$send?$send:0;$month=$month?$month:0;$day=$day?$day:0;$year=$year?$year:0;<br>
return mktime($hour,$minu,$send,$month,$day,$year);<br>
//return strtotime($date);<br>
}
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version
