开发者

convert string to date type in php

I have 3 variable $day , $month and $year and I want to create a date variable with these 3 variables开发者_StackOverflow社区 in this fromat : yyyy-mm-dd in php.

$year variable is a persian year for example $year= 1390

this code works properly but not for persian date :

date("d-m-Y", mktime(0, 0, 0, $fMonth, $fDay, $fYear));

How I can do it ?


http://ir.php.net/manual/en/function.mktime.php

Usage:

$myTime = date("d/m/Y", mktime(0, 0, 0, $month, $day, $year));


So you'd want something like this:

date("d-M-Y", mktime(0, 0, 0, $month, $day, $year));

EDIT: Oops, sorry, fixed.


I'm not sure what you mean by date variable but. You can try these.

mktime()

mktime(0, 0, 0, $date, $month, $year)

or you can create a DateTime Object

$date = new DateTime('2000-01-01');

or you can try strtotime() if you have strings in your variables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜