1

I'm a newbie to this UNIX Timestamp concept. So got stuck with a little issue. I want to extract the Time(in hr:min:sec format and attached with am/pm word) from UNIX Timestamp (e.g. 1335959743). Can you help me in achieving the desired time format along with the string am/pm attached to it. Thanks in Advance.

PHPLover
  • 1
  • 51
  • 158
  • 311

3 Answers3

2

Here:

date('h:i:s A', $timestamp);

The "h" is lowercase to show time in format AM/PM. If you want 12/24, use "H" (uppercase).

ivanargulo
  • 326
  • 1
  • 5
  • Thanks once again for your precious help. Your magic did the trick for me. I've marked your answer as right. – PHPLover Jul 04 '13 at 12:47
1

The date function is what you need:

$timestamp = time();//or whatever your timestamp source is
date('h:i:s A', $timestamp);
Expedito
  • 7,771
  • 5
  • 30
  • 43
1

Been asked before converting-a-unix-timestamp-to-formatted-date-string

echo date("H:i:s a",$timestamp);
Community
  • 1
  • 1
Moob
  • 14,420
  • 1
  • 34
  • 47