Talking with PHP

by

in
Talking with PHP
Talking with PHP

I need the current time then I call the php function – time() and get the current Unix timestamp. Then function time() returns the second measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). Say for, in my website users can register for free for one year. I need to calculate an account expiration time after one year. How can I calculate the expiration time. I need to add one year with the account creation time. We may get the the date and time of account expiration using following code.

[sourcecode language=”php”]$expiration = date( ‘Y-m-d H:i:s’, time() + (365 * 24 * 60 * 60) );[/sourcecode]

I have another easy solution. See bellow.

[sourcecode language=”php”]$expiration = date(‘Y-m-d H:i:s’, strtotime( ‘now + 1 year’ ) );[/sourcecode]

Everyone knows PHP is a flexible language. In the second statement, it seems I am talking with php. ha ha ha


Comments

4 responses to “Talking with PHP”

  1. Nice share…….

  2. Whenever I forget this, I browse your site and re-memorize.

    Thank you for sharing this.

  3. perlu memeriksa:)

  4. Above is useful tips.
    I want to ask you a off topic question, which about javascript.
    “alert(‘Hello World’);” It’s a simple function of Javascript but my question is how many digit should be set in replace of “Hello World”? Sometimes i set 15+ digit it show the message but if i write something negative like “Don’t leave this page” it don’t show the message but if i write something positive between 15-30 digit then it show the message. Why its happen? And How much digit should i write in replace of “Hello World”?
    Hope that you will reply this Question.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.