Due to the advent of the era of big data, the network information resources are exploding, which not only makes users hard to find available information but also makes the problem of information overload more serious. It is not difficult to see that the recommendation system is one of the effective measures to improve the above problems. In order to improve the user cold start problem and data sparseness problem, this paper proposes a clustering algorithm based on weighted distance and user preference of incorporating time factors. Firstly, this paper mitigates the user's cold start problem by introducing a user-user attribute matrix that constructed by the user's basic objective features, and the improvement of the sparsity problem is mainly through the introduction of project features. Since the characteristics of the project can reflect the user's preference from the aspect of content, as well as the sum of the project features is far less than the number of projects. Secondly, the user-item attribute total score matrix of the small dimension is obtained by introducing the project feature into the user-item score matrix. Last but not least, the project features are also introduced when constructing the user-project attribute preference matrix with the TF-IDF algorithm. At the same time, we also consider the influence of user interest drifts over time on user preferences. Based on the above three matrices we can get the weighted Euclidean distance and then use the K-Means algorithm for clustering. This article takes the recommendation of a movie as an example. The experimental results on the MovieLens data set show that the proposed algorithm has better quality and performance than other related algorithms.