Generally, to file for divorce in Utah, you or your spouse must have lived in a single Utah county for 3 months or more right before filing. There are other ways to qualify, read the Utah Code for more details.
Utah Code Section 81-4-402(1).
If you need a custody order for a child under 18, usually the child needs to live in Utah with one parent for at least 6 months before filing. There are exceptions. Our Finding Legal Help page has resources if you need help.