code : <body> <? date_default_timezone_set('Asia/Katmandu'); $d = date("d/m/Y"); $e =date("Y",$d); echo "$e"; ?> </body> if i want to show $e = "2009" but when i run it's show "1970" i don't understand ,what's happen?
The date function is run on a timestamp, you are passing a string representation of a date instead. Doing so results in an invalid timestamp. The first timestamp is somewhere in 1970. So you can just do: $e = date('Y'); PHP: Or: $e = date('Y', mktime(0, 0, 0, 10, 11, 2009)); PHP:
i write <? date_default_timezone_set('Asia/Katmandu'); $d = date("d/m/Y"); $e = date('Y',mktime($d)); echo "$e"; ?> It's good.Thank you very much