-1

OK does somebody know how to save date and time where something is posted? I am making school website and i add news but I want to get date and time and save it(IK how to save :P). I only know how to use C# version of gettime/getdate

Ile Popivanov
  • 95
  • 1
  • 1
  • 7
  • Start with the manual http://php.net/manual/en/function.date.php – Funk Forty Niner May 07 '16 at 20:06
  • Possible duplicate of: https://stackoverflow.com/questions/470617/get-current-date-and-time-in-php. I normally don't say this, but did you try Googling "get current date php"? The first five links are probably what you want. – The Unknown Dev May 07 '16 at 22:06

1 Answers1

0

I am assuming you already have a form with which you are posting the content. Once you have posted the content, you can include the following php code:

$post_time = time();

$post_time would then contain a timestamp. It represents the amount of seconds that passed after January 1st of 1970 and is a commonly used method of storing time: Documentation

If you would like to use that timestamp to display the exact date and time you posted the message, you can do something similar to:

echo "Posted on: ".date('l jS \of F Y h:i:s A',$post_time );
  //outputs something similar to:
  //Posted on: Monday 8th of August 2005 03:12:46 PM

Let me know if that worked for you.

Webeng
  • 7,050
  • 4
  • 31
  • 59