To improve recommendation systems' accuracy and customization while preserving user privacy, this study introduces a federated learning-based dynamic recommendation model, D2PDRF. Utilizing an attention mechanism, the model adjusts the blend of long-term and short-term interests, enhancing system adaptability. By integrating differential privacy with federated learning, user privacy is safeguarded. Tests on public datasets show the model enhances recommendation precision and personalization, ensuring data confidentiality.