If I compare two DateTime with two different time zone, there is a problem, or I should make him in the same time zone ?
Example :
DateTimeZone a = new DateTimeZone("Pacific/Kiritimati");
DateTimeZone b = new DateTimeZone("Pacific/Gambier");
DateTime dateOne = new DateTime(a);
DateTime dateTwo = new DateTime(b);
if (dateOne.compareTO(dateTwo) == 0) {
// yes
} else {
// no
}
Thnak you. (sorry for my bad english)
People always have confusion about dates and timezones. A date (or a time, or datetime) is a specific instant in time. This instant is the same in all the Universe, so it is independent from timezone, and it is usually represented as UTC (Universal Time) or Z (Zulu time). Timzone is a modification of UTC to show relative solar time for this specific zone in Earth. By setting the timezone, you're just telling that this datetime is relative to this specific timezone, but internally it will be still represented as UTC. In this case, they should be different if the timezones have a different UTC offset.