-2

Possible Duplicate:
How to convert Unix timestamp to hhmmss?

I have a timestamp in the format of:

1330559989 

How to check the hours in the timestamp is in between 6 hours and 23 hours?

Can someone help me please?

0

3 Answers 3

2

date('H', 1330559989) will give you the hours in 24h format with a leading zero, in this example: 23.

There is also a specific function for the hour of a timestamp called getdate which offers an array interface to that information (demo):

getdate(1330559989)['hours']; # 23 
Sign up to request clarification or add additional context in comments.

Comments

2
$hrs=date('H', 1330559989); if ($hrs>= 6 && $hrs<= 23) { // your code } 

Comments

1

If you want to check the time between now and that given timestamp, then you can use:

<?php echo date("H", strtotime(now)-1330559989); // Displays the difference from now. echo date("H", 1330559989); // Displays that time! ?> 

Hope this helps! :)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.