Is Sunday 星期天 or 星期日? I am using the ChineseSkill app to learn Chinese and I learned that 'Sunday' in Chinese is 星期天 (xīngqītiān). However, sometimes on the internet I see 星期日 (xīngqīrì).

Are both correct? Why is there such a variation in usage?
In theory, 星期日 should be correct.

The concept of a week was introduced from the west, the name of days came from the Sun, the Moon and the stars. When they were introduced to China, only Sunday was preserved, the other days were renamed from 1 to 6, so they became 星期日 (Sun -> 日), 星期一 ... 星期六.

But in Chinese, 天 and 日 could be used for the meaning of day both. So the people started to say 星期天 instead of 星期日, and the original meaning (i.e. Sun) was lost, which would be a "misuse".

Nowadays 星期日 and 星期天 are both correct. Basically in a formal context, such as in news, 星期日 is used more than 星期天.

话说“星期日”与“星期天”