Port Java date utils to php