November 30, 2010

Calculate the time stamp of year

Question by Mawg

Given that I have $num_years, how can I add it to Time() to get a time stamp $num_years hence?

Answer by Angus

strtotime("+$num_years years") will give you a timestamp $num_years years in the future.

Answer by Starx

Well if you looking for the timestamp for just that time then use mktime

mktime(0,0,0,0,0,$noOfYears);

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

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!