There are a lot of misconceptions and misunderstanding about how the moon and its cycles actually behave. The moon is not a nightlight that rises at sunset and sets at sunrise and provides light all night when the sun is down. It only rises at sunset and sets at sunrise when it's full. At other points in its cycle, it can rise or set at any time of the day or night, or be high in the sky at any time of day or night, all depending on its phase. When it's near new, it'll actually rise and set with the sun, and be in the sky all day... though it'll be difficult to see, because it'll be mostly dark and appear very close to the brilliant glare of the sun.
So to understand what it really does and why, let's take a look at how the mechanics of the thing actually work.
This is a system like Earth-Luna. We're looking down at it from above the North Pole. The sun is some distance off the right edge of the diagrams, lighting everything from the right. The planet rotates counterclockwise, making one full turn each day. The moon revolves around the planet, also moving counterclockwise, but much more slowly... one complete revolution every month.
The whole planet-moon system is also moving counterclockwise around the sun, even more slowly - once per year - but we'll ignore that; it's not really relevant to what we're looking at here.
We have a stick-figure observer (not to scale; none of this really is) standing on the planet looking at the sky. We'll say he's at the planet's equator, and his planet has no significant axial tilt, so we don't have to worry about some complicating issues that aren't really relevant here. This also means that day and night will each be twelve hours long, with the sun rising at about 6 AM and setting at about 6 PM.
It doesn't really matter where on the equator our observer is standing... because the planet rotates so much faster than the moon revolves around it, or it revolves around the sun, longitude just causes a time zone effect. The sky our observer sees now is very nearly the same sky that someone ninety degrees east of him saw six hours earlier, or someone ninety degrees west of him will see six hours hence.
We'll also assume that the weather is always clear in the tropical paradise he lives in, and the horizon is uncluttered, so he can always see everything that's there to be seen in the sky.
So as we look in on our observer here, what is that sky he sees? Well, he's standing right on the terminator, the line that divides day and night. West of him, the planet's lit by the sun, while east of him the planet is in its own shadow. He's being carried eastward into night by the rotation of the planet. That means that it's sunset, and looking at the diagram, we can see that the sun is going to be low on his western horizon. In the other direction, the moon is low on his eastern horizon, and he's rotating towards it, so that means it's rising. The side of the moon towards him is the side of the moon towards the sun, so it's fully lit - a full moon.
Now, the moon looks like it should be in the planet's shadow - and it might be, which would make it a lunar eclipse - but it probably actually isn't. The diagram isn't in scale, the distances between the bodies should be much larger than they appear, and, in three dimensions, the planes of the orbits probably don't quite line up, so the moon's likely to actually be a little above the planet's shadow, or a little below its shadow, but probably not quite in it - which is why we don't have a lunar eclipse every full moon, but only once in a great while when everything happens to line up perfectly.
So now we'll advance a few hours into the future, to our stick figure's local midnight. He's still standing in the same spot looking at the sky, but the planet has rotated ninety degrees, carrying him with it. It's full night now where he is, with the sun out of sight on the opposite side of the planet. The moon, slow-moving as it is, has also stayed in very nearly the same spot, but because the planet is rotating beneath it, it's now directly over our observer's head. The face of it that's towards the planet is still the face that's lit by the sun, so it's still a full moon.
A few more hours, and the rotation of the planet has carried our observer clear around to the sunrise line. This has brought him back to where he can see the sun, rising on his eastern horizon, but also carried him away from the moon, which - again, despite not actually having moved significantly in its orbit - is now low on his western horizon, setting. And still, as before, full.
A few more hours, and our observer has been carried around so he's directly beneath the sun. It's noon where he is, bright daylight with the sun directly overhead. He can't see the moon - it's still there, still full, but around on the other side of the planet, shining down on the antipodes, and there's a ball of rock and iron thousands of kilometers thick blocking his view of it.
Now, so far, this looks pretty much like what I said it doesn't do, right? Well, that's because we've only looked at the full moon. I am, here, going to arbitarily define this system's month - the time it takes for the moon to complete one orbit around the planet - as 32 days, which is a bit longer than Luna's month, but which will make my diagram-drawing easier later on.
So we're going to advance our clock by eight days here. Given the 32-day month, that means that the moon will have traveled a quarter of the way around its orbit. It's sunset again, and Mr. Stick Figure is standing in his usual spot, looking at the sky. We can see, again, that he's at the terminator, being carried from day into night by the planet's rotation. The sun is low on his western horizon... but the moon is not rising as the sun sets. It is, in fact, nowhere to be seen. It's moved in its orbit so it's no longer directly opposite the sun, which means that when the sun sets on our observer, the moon is clear around on the other side of the planet where he can't see it.
Our observer waits a few hours, though, and, finally, at midnight, after six hours of moonless night, the rotation of the planet carries him around to where he can see the moon. It's now, at midnight, rising on the eastern horizon. He's also no longer looking at the fully lit face. Because the moon is beside the planet relative to the sun now instead of beyond it, the face turned towards the planet is now only half lit, with the other half dark, in the moon's own shadow. That makes it a quarter moon. (Yes, half-lit, quarter moon... I didn't make up the terminology. It's because the moon is a quarter of the way through its cycle.) Because it's waning - moving from full to new - it is, specifically, the last quarter.
Six hours later, the moon has climbed high in the sky - again, not because of its own movement, but because of the rotation of the planet beneath it. It's directly overhead - still half-lit and half-dark - when the planet's rotation carries our observer back around to the dawn terminator, and the sun begins to peek over his eastern horizon.
After a shorter-than-usual interval - about three hours; it's about 9 AM where our observer is - we can see that the sun is well up in his sky. It's broad daylight now. The moon is also still well up in his sky, though no longer directly overhead. He'll be able to see here its lit portion hanging in a blue sky.
At noon, when the sun is directly over our observer's head, the moon is finally setting in the west, having been visible in the daytime sky all morning.
So we skip ahead another eight days. The moon revolves another quarter of the way around the planet. It's now between the planet and the sun. Probably not directly between... like the full moon, on the rare occasions that the new moon is directly in line with the planet and the sun, it produces an eclipse. A solar eclipse, in this case. But usually it's not directly in line, but a little above or below, and thus eclipses are uncommon, and don't occur every new moon.
The moon is, however, in the sky very near the sun. This means that it's on the western horizon at sunset, setting with the sun. The side of it that's lit is the side directly away from the planet. The entire near side is dark - a new moon.
The moon having set with the sun at dusk, there's nothing but the stars in the sky at night. The sun and moon are both on the far side of the planet, unseen.
When sunrise rolls around again, the moon, still near the sun in the (now) eastern sky, rises right along with it.
And at noon, when the sun is high in the daytime sky, the moon is right there with it, directly overhead. Because it's new, though, the lit side away from the planet, it'll show only a thin crescent, if anything at all, and even that is likely invisible in the brilliant glare of the sun.
Another eight days will bring the moon around another quarter-turn. It's now directly overhead at sunset, with half of it - the other half, this time - lit by the sun. This makes it a quarter moon again (I told you, I didn't make up the terminology here) - this time, the first quarter.
And at midnight, the moon sets.
And the rest of the night is moonless. When the sun rises on our observer, the moon is on the opposite side of the planet from him.
The moon rises at midday, though, when the sun is directly overhead, and through the afternoon it climbs higher in the sky until it's in turn directly overhead when sunset rolls around again.
And in another eight days, the moon completes its orbit around the planet, and is back to the full position, back where we started.
Now, we can see several things from these diagrams. One of these is that time down on the surface of the planet depends on the rotation of the planet relative to a sun that's, for practical purposes, fixed in space.
Another is that moonrise and moonset also depend on the rotation of the planet. The moon does move in its orbit around the planet, but only slowly, so when it rises and sets depends on when the planet turns to bring the observer around where he can see its slowly-changing position in orbit, not on the slow motion of the moon through space.
And another is that the phase of the moon depends not on the rotation of the planet, but on the revolution of the moon around the planet. As long as it's in the same part of its orbit, relative to the position of the sun, it'll be the same phase from anywhere on the planet at any time of day - and in any month.
Add these all up, and we can see that the time at which the moon rises and sets is determined by its position in its orbit relative to the sun - in other words, its phase. A moon in the same phase will always rise and set at roughly the same time every month, and in each phase, it'll rise and set at a different time. To wit:
This is, of course, a gradual progression. Each day, the moon rises a little later and sets a little later - a little less than a hour later, for Earth's moon, about 45 minutes later for the example moon with its 32-day month. This does mean that the moon moves enough in its orbit from one day to the next that it should be visible in the diagrams, and it isn't. This is entirely because I'm lazy.
Another thing to notice is that the moon, throughout its orbit around the planet, has kept the top of the "A" pointed directly at the planet... always the same side towards its planet, throughout its cycle. Sometimes lit, sometimes dark, but always the same side. Almost all of Sol System's major moons, including Luna, do this. It's called "tidal locking", and, from the evidence, is pretty normal for moons. Comparing the moon's orientation in each phase, you can see that this means that the moon has rotated completely around exactly once over the course of its orbit. It always keeps the same face towards the planet, but it rotates to do so... it just rotates at the same rate that it revolves. Points on its surface experience a day/night cycle, because it's not always keeping the same face towards the sun, but its days are a month long. Also, from the point of view of an observer on the moon, the planet will remain fixed at a single point in the sky.
Now, that's one moon. What if, this being some sort of speculative fiction world (or Mars... but Mars is more complicated), there are two moons? Well, the moons' phases are determined, like a single moon's, by their position in their orbit around the planet, relative to the position of the sun. If they're in the same part of their orbit, they'll be the same phase, and rise and set together.
Just like our single-moon world, here both moons are full, and rise together at sunset, set together at sunrise, and are directly overhead at midnight.
But... this isn't always going to be true. In fact, it won't often be true. Because of the way orbital mechanics work, moons in different orbits won't be moving at the same speed. The outer moon, Moon A here, will move, in absolute terms, faster than the inner moon, Moon B. The inner moon hasn't got as far to go, though, so despite moving slower, it'll actually take Moon B less time to complete an orbit around the planet than it does Moon A. It's going slower, but it's got the inside track. This means that the only time the moons will both be in the same part of their respective orbits is as Moon B is overtaking Moon A, and then only for a brief time before Moon B passes and moves ahead.
And again, while it appears that Moon B is directly between Moon A and the planet, occulting Moon A, it usually actually won't be. The angles of their orbital planes probably aren't exactly the same, so most of the time they'll be offset a little vertically as they pass. Even a degree of difference is significant... Sol and Luna are each only about half a degree across in Earth's sky, so a single degree of difference in the angle of their orbital planes as they pass means that their near edges will be a full Luna-width apart at their near approach.
The orbital planes do have to cross somewhere, though, so it's likely that every so often their cycles will line up perfectly, and Moon B will pass directly in front of Moon A. It'll happen only rarely, though.
We've already arbitrarily defined Moon A's orbital period as 32 days, so let's define Moon B's shorter orbital period as 24 days. (Again, numbers chosen to simplify my diagram-drawing.)
This means that eight days after the previous set of diagrams, Moon A will have moved a quarter of the way around its orbit, and be in the last quarter, as when it was the only moon. Eight days is a third of Moon B's orbital period, however, so it will have moved a third of the way around its orbit, and pulled ahead of Moon A.
At sunset for our observer, neither moon is in the sky. The sun is going down in the west, and both moons are behind the planet out of sight.
At midnight, the rotation of the planet brings our observer around so that Moon A is just rising above his horizon. As before, it's last quarter, half of the near face lit and half of it dark. Moon B, being a little further along, is still below the horizon, out of sight, however.
About 2 AM, the planet has rotated far enough that Moon B also clears the eastern horizon. Moon A, having been up for a couple of hours, is about thirty degrees above the horizon when Moon B is just rising. Moon B is also somewhat past the last-quarter position. The face of it that's towards the planet, towards the observer, is not half-and-half, but more dark than light. It's not a quarter moon, it's a fat crescent. As it rises, we now have two moons in our observer's sky, in different spots, and in slightly but distinctly different phases.
When the sun rises a few hours later, Moon A is directly overhead, still at its last quarter, and the waning crescent of Moon B is high in the eastern sky and climbing.
At noon, Moon A sets in the west, leaving Moon B still above the western horizon, a fat crescent with its rounded belly facing upwards towards the sun and its horns pointed down at the horizon. Moon B follows A down a couple hours later, as the sun is beginning to slide down the western sky.
So we skip ahead another eight days. This brings Moon A another quarter of the way around its orbit to new, and Moon B another third of the way around - almost, but not quite, to the first quarter. When our observer looks up at dusk, Moon A, dark and invisible, is setting in the west with the sun. Moon B is still above the horizon, and partly lit, not quite half lit. It's the same fat crescent as eight days earlier, in fact, but on the other side now... waxing instead of waning.
The rotation of the planet brings the horizon up to cover Moon B a few hours later, about 10 PM. By midnight, both moons are out of sight below the horizon.
At sunrise, the new Moon A rises as well, though it's invisibly dark and obscured by the glare of the sun anyway. Moon B is still well below the horizon, though, out of sight behind the planet.
Moon B's crescent rises about 10 AM, to join both the sun and the unseen Moon A in the daytime sky. By noon, it's well above the horizon, and it spends the rest of the day in the sky, not setting until after dark.
Eight more days brings Moon B the rest of the way around to full again. The laggard Moon A is only to the first quarter, though. When the sun is setting in the west, the full Moon B is just rising in the east, and Moon A, only half-lit, is directly over our observer's head.
By 9 PM, it's full night, with the sun well below our observer's horizon. Both moons are high in the sky, now, showing different phases, and far apart in the sky. The full Moon B is in the eastern sky, about halfway between the horizon and the zenith, the point directly above our observer's head. Moon A, at first quarter, with the sunward half lit and the other half dark, is in the western sky, also about halfway between the horizon and the zenith, putting the two moons about ninety degrees apart.
At midnight, Moon A sets in the west. The planet's rotation has now brought Moon B to the zenith.
As the sun rises, Moon B also sets.
Skip ahead a final eight days, and Moon A has moved opposite the sun again, and grown back to full. Moon B is well ahead in its shorter orbit, though, having moved around to where it's only a waning crescent. As the sun sets where our observer is, he can't see Moon B, though. It's way around behind the planet. Moon A, opposite the sun, rises on his eastern horizon as the sun sets on his western horizon.
At midnight, Moon A has risen so that its full disc is directly over our observer's head. Moon B is still nowhere to be seen.
At 2 AM, Moon B's crescent is finally visible on the eastern horizon, its rounded belly facing down towards the yet-unseen sun, and its horns pointing up away from the sun. The full Moon A has passed the zenith and is dropping towards the western horizon.
Moon A, opposite the sun, sets in the west as the sun rises, leaving the crescent of Moon B alone, still high in the increasingly bright sky.
At high noon where our observer is, the sun burns down from directly over his head, and Moon B's crescent is still visible in the daytime sky, though now low on the western horizon.
And that ought to pretty much do it. I could make more diagrams, but they wouldn't really demonstrate anything new, so we'll stop here.
So what we've learned here:
Moon phases are determined by where the moon is in its orbit, in relation to the sun.
The moon can rise or set at any time of the day or night, and when the moon rises and sets is also determined by where the moon is in its orbit, in relation to the sun.
And, therefore, when it rises and sets is determined by its phase, and vice versa. The one can be determined from the other, by the list above.
The moon can be and often is visible in the daytime sky, and can be and often is absent from the night sky.
If there's more than one moon, their months will be of different lengths, so their phases won't stay in sync with one another. Nor will their times of rising and setting.
Moons at similar phases will be close together in the sky; moons at different phases will be far apart in the sky.
But because the visible sky covers a full half of the celestial sphere, you can still have two moons in the sky at the same time at very different phases, even though they're far apart.
The lit side of a partial moon will always be oriented towards the sun, even when the sun isn't visible in the sky from the surface.
Most moons always keep the same face towards their planet throughout the month. This doesn't mean that they don't rotate, though. Rather, it means that they rotate exactly once per revolution - their day is the same length as the month.
And eclipses and occultings are less common than a two-dimensional not-to-scale diagram might lead you to believe.
Left as an exercise for the reader is the question of what these diagrams look like from the perspective of an observer living on the moon... a moonbase on a moon like Luna, or an Earthlike moon orbiting an even bigger planet like Jupiter, possibly one with other significant moons.
Oh, yeah, and Mars? The Martian Moon B, Phobos, orbits so low and fast that it takes it less than a third of a Martian day (Martian days are only about forty minutes longer than Earth's) to complete a full orbit around Mars. That means that it moves so fast that it overtakes the Martian surface below it. It rises in the west and travels west-to-east across the sky, contrary to the apparent motion of sun and stars - and this is not just an illusion produced by the rotation of the planet beneath it, but Phobos's actual orbital motion - changing phase visibly as it goes, and sets about six hours later in the east, as it overtakes the horizon and dives below it.
The Martian Moon A, Deimos, is not quite so fast, but is still fast enough that it almost keeps up with Mars's rotation. It takes it only a little more than a Martian day to complete an orbit, which means that the Martian surface overtakes it only very slowly, gaining about a fifth of a rotation each day. This means that Deimos rises in the east, but creeps across the sky only slowly, and doesn't set in the west until two and half days later, during which time it's gone through the entire moon cycle twice.
Yeah, I said it was complicated.