DateTime would be your friend.
First, if your php config dosen't already set it up for you, set your default timezone by:
date_default_timezone_set('XXXX');
XXXX stand for a value out of the List of supported timezones
initialize your date by:
$date = new DateTime();
To get your timestamp you can use now:
$timestamp = $date->getTimestamp();
As earlier said the output (format) depends on your timezone. You set your default timezone earlier but you can change it all the time, as you need.
To format the date you can use this:
$12h = $date->format( 'h:i:s a' );
$24h = $date->format( 'H:i:s a' );
To read more about DateTime look at the DateTime class manual.