I made this code so that it can tell the program to get Morning (AM) or evening (PM) INFO

function Tms()
 {
  $time = time();
  $time1 = mktime(12,00,00);
  if ($time > $time1)
  {
   $Time = 'AM';
  }
  else
  {
   $Time = 'PM';
  }
  echo $Time;
  echo "<br>";
  echo $time;
  echo "<br>";
  echo $time1;
 }

results running this code:
------------------
PM
1131844349
1131883200
-----------------------
The PM part is correct as my watch says it is 8:13 PM
but the second and the third line comfuses me as i have no idea what those #s mean but the fact that they have to do with time.

If some one can explain what those #s are and how can i convert them to regular time would be nice.

OR
if someone can tell me how to get some code to tell if it is AM or PM would be nice as i want my program to detect if it is AM or PM and let people get right information they need depending on if it is evening or moring.

Recommended Answers

All 2 Replies

You don't have to get really advanced to get the time :) There is already a built-in function for that that can do all of that in one line.

if (date('A') == 'AM')
{
  // it is AM
}
else
{
  // it is PM
}

I tried it and date('A') wont work but time('A') works.

Thanks for the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.