You probably can’t go to any civilized place on the planet without hearing the music of The Beatles on a daily basis. Their music has dominated the pop culture landscape for well over 50 years, with 27 No. 1 singles in the US alone, and well over 100 million albums sold.

But in “Yesterday” — the latest film from Danny Boyle, perhaps the most eclectic director working today (“Slumdog Millionaire,” “127 Hours,” “Trainspotting”)— a struggling young musician named  Jack (Himesh Patel ) is ready to give up on his ambitions after a disastrous appearance at a music festival. His longtime friend and manager Ellie (Lily James) is heartbroken by his decision, and tries to convince him that a miracle might be just around the corner.

It turns out that she’s remarkably prescient, for while Jack rides his bike home that night, a worldwide power outage occurs for 12 seconds and he’s hit by a bus in the darkness. When he awakens in a hospital with his two front teeth missing, he also finds that no one around him knows who The Beatles are or recognizes any of their songs.

Searching the Internet, he finds that there are literally no references to The Beatles, and his record collection is devoid of their albums as well. The Rolling Stones exist, but the Beatles-derivative band Oasis has also been wiped off the planet’s collective consciousness. Jack sees a golden opportunity in all of this, and proceeds to play from memory and record as many of the Fab Four’s tunes as he can, claiming the songs as his own.

He immediately finds himself on a rocket ride to fame, as present-day superstar Ed Sheeran (playing himself with comic aplomb) sees him on a local TV show and hires him as his opening act on tour. But when Jack starts getting more fan mania than Ed himself and Ed’s comically ruthless manager (Kate McKinnon) pushes to make him the biggest artist of all time, things start to get complicated on both his professional front and his relationship with Ellie.

“Yesterday” is a terrifically good time at the movies, with Boyle deftly handling the fantasy, comedy and romantic elements with total grace. Patel’s performance as Jack should be an instant star-maker for the actor, who has previously only worked in British television but has a magnetic ability to earn empathy for a character that might have just seemed like a selfish con artist in the hands of most actors.

As Ellie, James is clearly channeling a young Keira Knightley with irresistible winsomeness, but the world needs more of that kind of delightful charm, especially when Knightley has matured into more complex roles. Sheeran brings surprising comical zing to his part, as he is increasingly baffled by Jack’s inexplicable ability to craft timeless classics like “The Long and Winding Road” in a bar bet on who can compose the best song within ten minutes. McKinnon brings a zesty sense of comic ruthlessness and greed to the table, delivering some of the funniest moments.

The screenplay  by Richard Curtis— the mastermind of rom-com classics “Four Weddings and a Funeral,” “Notting Hill” and “Love Actually”— stands up to that prior wonderful trio, grounding everything in relatable characters and, of course, ample opportunities to hear the greatest pop songs ever through the fresh voice and adaptations of Jack.

Curtis  layers in some intriguing moral quandaries as well, as Jack lives in constant fear of someone catching on to his ruse, or the world suddenly remembering  The Beatles again. Nearly everyone has faced a moment in life where they could get away with a scam or a shortcut that is highly questionable, and the way that Jack faces his is both moving and entertaining.

The film also provides some thoughtful insights into the creative process of great songwriting, as Jack and his producers put their own fresh tweaks on the tunes, turning “Help” into a revved-up rocker that sounds like a Ramones tune, for instance.  And when Jack realizes he’s going to face questions about what inspired each song, he heads to key places like Liverpool to try and get his own understanding of places like Penny Lane and Eleanor Rigby’s grave. 

But the most fascinating part of this unexpected charmer is being forced to consider what would happen if the whole world was deprived of The Beatles’ joyous music. “Yesterday” makes you appreciate the magical soundtrack their music has played in all our lives since the early 1960s, and will hopefully continue to color our lives for generations to come.

“Yesterday”: A