In the era of big data, prediction has become a fundamental capability. Current prediction methods primarily focus on sequence elements; however, in multivariate time series forecasting, time is a critical factor that must not be overlooked. While some methods consider time, they often neglect the temporal distance between sequence elements and the predicted target time, a relationship essential for identifying patterns such as periodicity, trends, and other temporal dynamics. Moreover, the extraction of temporal features is often inadequate, and discussions on how to comprehensively leverage temporal data are limited. As a result, model performance can suffer, particularly in prediction tasks with specific time requirements. To address these challenges, we propose a new model, TE-LSTM, based on LSTM, which employs a temporal encoding method to fully extract temporal features. A temporal weighting strategy is also used to optimize the integration of temporal information, capturing the temporal relationship of each element relative to the target element, and integrating it into the LSTM. Additionally, this study examines the impact of different time granularities on the model. Using the Beijing International Airport station as the study area, we applied our method to temperature prediction. Compared to the baseline model, our model showed an improvement of 0.7552% without time granularity, 1.2047% with a time granularity of 3, and 0.0953% when addressing prediction tasks with specific time requirements. The final results demonstrate the superiority of the proposed method and highlight its effectiveness in overcoming the limitations of existing approaches.