'Getting fat' depends on calorie intake vs calorie expenditure, so if you eat more calories than you burn, you will get fat, regardless when you eat. But a study in america showed many people ate near to 20% of their daily intake at 8pm or later, which isn't good. If you eat strictly healthy, then you're not going to put weight on anyway, but if you eat most of that food late at night? there is a chance your body will store it as fat. If you haven't got the best diet, and you eat a lot of food late at night, then your body will do nothing with that except store it as fat. The reason for this? Your body doesn't need a lot of energy at night, so if you give it a lot, it has no use for it.
I tell my clients and anyone that wants advice, to try and not eat food within 1-2 hours of sleeping. You want to eat most of your calories during the day, as that's when your body needs energy to deal with the daily tasks. Also, most people who are overweight, tend to eat a small breakfast, bigger lunch, and then an even bigger dinner. By simply swapping that around, so you have a good size breakfast, slightly smaller lunch, and a smaller dinner, that in itself can lose weight. Your body does burn calories whilst you sleep, because it is still functioning obviously, but if you give it more than it needs, it will store it as fat.
So, try and be smart about it, feed your body when it needs energy. Eat for purpose, not just for the sake of it.
Try my 'get slim' healthy eating plan