Marc Rasmussen
Marc Rasmussen

Reputation: 20565

Getting day of week from timestamp PHP

i am trying to get the day of week from a timestamp:

an example of the timestamp could be:

2014-09-14 18:28:11

I have tried with the following code:

$date = date("D", strtotime($activity[$i]['timestamp']));

However the result i get here is:

Thu

which should have been sunday?

Also is it possible to get it as a full discription instead of a short version of the day name?

Upvotes: 0

Views: 435

Answers (1)

Bird87 ZA
Bird87 ZA

Reputation: 2160

Answer to part two of the question is that you can just use l (lowercase 'L') and it'll output Sunday instead of Sun.

$date = date("l", strtotime($activity[$i]['timestamp']));

As for the first part, it probably output Thursday, 1 January 1970 because it received an error instead of an actual date as argument to strtotime.

Upvotes: 2

Related Questions