Archive for June, 2008

Using Mysql date functions

Sunday, June 29th, 2008

This is something that slipped by me for a long time.

Like many other developers I know, I have written a function that takes a date from mysql (In any of the relevant formats, usually datetime though) and then formats it (Using substr() or strtotime() and date()) with PHP into a nice human readable format for display on the website.

There is a more elegant solution however.

(more…)

How do I find the date a week starts given the week number

Wednesday, June 25th, 2008

I came accross this problem recently while developing a time tracking application.

Typically, I have found that when viewing timesheets people prefer to be able to see the week at a glance. For this reason I will normally store them in a database with three int (day (From 1-7), Week (From 1-53) and year (From 0001 to 9999)). This allows me to easilly pull a two dimensional array from the database for output into the virtual timesheet

(more…)