views:

175

answers:

2

I'm looking to convert this line of code to PHP's mktime():

Calendar timeStartPoint = Calendar.getInstance();

timeStartPoint.set(11, 0);
timeStartPoint.set(12, 0);
timeStartPoint.set(13, 0);
timeStartPoint.set(14, 0);
timeStartPoint.set(5, monthStartPoint ? 1 : 5);
timeStartPoint.set(2, 0);
timeStartPoint.set(1, 2004);

I imagine 1 is year, 5 is month of some type, and the rest I'm not sure of. I've looked around online and managed to find documentation for java.util.calendar.set(x, x) however none of them list the fiend integer names.

+4  A: 

The meaning of the constants is as follows:

Calendar timeStartPoint = Calendar.getInstance();

timeStartPoint.set(11, 0); // hour of day
timeStartPoint.set(12, 0); // minute
timeStartPoint.set(13, 0); // second
timeStartPoint.set(14, 0); // millisecond
timeStartPoint.set(5, monthStartPoint ? 1 : 5); // day of month
timeStartPoint.set(2, 0); // month (zero-based!)
timeStartPoint.set(1, 2004); // year

I am not fluent in PHP, but this should correspond to

$timeStartPoint = mktime(0, 0, 0, 1, ($monthStartPoint ? 1 : 5), 2004);
janko
Thanks a lot, I appreciate the help.
Don Wilson
A: 

Here's the javadoc:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#set%28int,%20int%29

For field reference used in the first parameter, take a look here: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#field%5Fsummary

silent