Around 10 weeks of age, fetuses begin to coordinate their movements into periods of activity and periods of inactivity (kind of like being awake and asleep). During the second half of pregnancy, these patterns become pretty stable  and by the later part of pregnancy (roughly 20+ weeks), the fetus is only active about 10-30% of the time.  This is why it can be so hard for a partner or friend or family member to feel a baby move. Once a woman can reliably feel a baby move, around 20 weeks, the baby is not active for that much of the day. My mother once sat next to me touching my pregnant belly for over an hour wanting to feel the baby move. Baby did not oblige grandma.
It turns out that babies tend to be most active at certain parts of the day. These circadian, daily patterns, emerge over time. Generally, these patterns are low levels of activity in the morning and way more activity in the late evening.  It’s also notable that babies are least likely to move when a mother is moving. In other words, when mom is up and active throughout the day taking care of her daily tasks like work or school or errands, baby is lulled by the movement into quiet alert time or sleep. But, when mom finally sits down in the evening to use the computer, watch trashy television, or try to go to sleep, it’s time for “fetus gone wild” – it also means that people have the best chance to feel a baby move during these quiet moments at the end of the day. It also translates into mom having a hard time sleeping because the baby is having a dance party.
Towards the end of pregnancy, the baby has a well-set sleep-wake cycle. About 75% of a fetus’ time is spent in either quiet sleep or active sleep (non-REM or REM sleep).  This cycle is identical to a newborn sleep-wake cycle: calm, sleepy baby by day/wild writhing baby by night.
So what to take away from this? Sleep pattern is pretty consistent inside and outside of utero. Remember how baby kicks and punches were keeping you up in the middle of the night in that 3rd trimester? Those same kicks and punches are going to be keeping you up in the middle of the night for a few months after birth. When the fetus is born, he or she will mimic this same daily cycle that he or she had in utero. Over the first few weeks of life outside the womb, one of the key jobs of a parent is to help the baby coordinate his or her activity schedule to the light and our own adult circadian rhythms.
Second, remember that babies were lulled to sleep in utero when the mom was moving around. One of the ways we can help very young infants to sleep is by mimicking the in-utero environment. Movement (rocking or walking), being wrapped up in a tight space (swaddling), and white background noise (like what a fetus can hear through the uterine walls)[a] can all be critical tools to help your baby sleep.
[a] See the article on The 5 Senses in Utero to understand why swaddling and white noise are powerful tools for helping a newborn settle.
 Robertson, S. S. (1990).
 DiPietro, J. A., Costigan, K. A., Shupe, A. K., Pressman, E. K., & Johnson, T. R. (1998).
 Aruini, Arduini, D., Rizzo, G., & Romanini, C. (1995).
 James, D., Pillai, M., & Smoleniec, J. (1995).