I have a table which holds different type of data. One of it are birthday dates:
ID | meta_key | meta_value
==========================
1 | birthday | 2011-30-01
2 | birthday | 2011-30-07
3 | other | not_related
With a known timestamp I would like to get all birthdays like
SELECT *
FROM table
WHERE meta_value = 'birthday'
AND UNIX_TIMESTAMP(STR_TO_DATE(meta_value,'%Y-%m-%d')) = 1296342000
which should return the first row (#1
) but doesn't . The reason is the timestamp has to be 1296345600
I did a sqlfiddle to double check that.
It seems the DST is causing the issue but why? Are those UNIX time based timestamps not all UTC? I'll get my timestamp with PHP's strtotime()
like
strtotime('2011-30-01')
Edit:
I can't compare strings directly cause I also like to get results from a certain "range" like "All birthdays from August to October"