$dt=date("y-m-d H:i:s"); This statement gives the current date in PHP
$strdt = preg_replace('/[^0-9]/','',$dt);
The above preg_replace function accepts a regular expression . and gives the characters specified in regular expression in the input string.
For example in above example the date will be stored as "2015-01-23 15:14:34" in the variable $dt. Now the $strdt will have the output as "20150123151434" that is only the numbers are accepted from $dt.
This is useful while uploading the file. The duplicate file name will not be exists for uploaded file.
$strdt = preg_replace('/[^0-9]/','',$dt);
The above preg_replace function accepts a regular expression . and gives the characters specified in regular expression in the input string.
For example in above example the date will be stored as "2015-01-23 15:14:34" in the variable $dt. Now the $strdt will have the output as "20150123151434" that is only the numbers are accepted from $dt.
This is useful while uploading the file. The duplicate file name will not be exists for uploaded file.
No comments:
Post a Comment