演示:



已相恋

代码:自行修改!可以修改成动态桃心!(每个模板引入的图标库都不一样!)


  1. <div class="textwidget custom-html-widget">
  2. <div style="text-align:center;">
  3. <img src="/content/uploadfile/202002/ec161581422463.gif" style="width:50px;height:50px;vertical-align:-20px;border-radius:50%;margin-right:5px;margin-bottom:5px;-webkit-box-shadow:1px 1px 1px rgba(0,0,0,.1), 1px 1px 1px rgba(0,0,0,0.1), 1px 1px 1px rgba(0,0,0,0.1);box-shadow:1px 1px 1px rgba(0,0,0,.1), 1px 1px 1px rgba(0,0,0,0.1), 1px 1px 1px rgba(0,0,0,0.1);border:2px solid #fff;" /><i class="el el-heart" style="color:#fe4365;"></i><img src="/content/uploadfile/202002/ec161581422463.gif" style="width:50px;height:50px;vertical-align:-20px;border-radius:50%;margin-left:5px;margin-bottom:5px;-webkit-box-shadow:1px 1px 1px rgba(0,0,0,.1), 1px 1px 1px rgba(0,0,0,0.1), 1px 1px 1px rgba(0,0,0,0.1);box-shadow:1px 1px 1px rgba(0,0,0,.1), 1px 1px 1px rgba(0,0,0,0.1), 1px 1px 1px rgba(0,0,0,0.1);border:2px solid #fff;" /> <br />
  4. 已相恋 <span id="htmer_time" style="color:#2a8601;"></span>
  5. </div>
  6. <script>
  7. function secondToDate(second) {
  8. if (!second) {
  9. return 0;
  10. }
  11. var time = new Array(0, 0, 0, 0, 0);
  12. if (second >= 365 * 24 * 3600) {
  13. time[0] = parseInt(second / (365 * 24 * 3600));
  14. second %= 365 * 24 * 3600;
  15. }
  16. if (second >= 24 * 3600) {
  17. time[1] = parseInt(second / (24 * 3600));
  18. second %= 24 * 3600;
  19. }
  20. if (second >= 3600) {
  21. time[2] = parseInt(second / 3600);
  22. second %= 3600;
  23. }
  24. if (second >= 60) {
  25. time[3] = parseInt(second / 60);
  26. second %= 60;
  27. }
  28. if (second > 0) {
  29. time[4] = second;
  30. }
  31. return time;
  32. }
  33. </script>
  34. <script type="text/javascript" language="javascript">
  35. function setTime() {
  36. // 博客创建时间秒数,时间格式中,月比较特殊,是从0开始的,所以想要显示5月,得写4才行,如下
  37. var create_time = Math.round(new Date(Date.UTC(2013, 4, 22, 0, 0, 0))
  38. .getTime() / 1000);
  39. // 当前时间秒数,增加时区的差异
  40. var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000);
  41. currentTime = secondToDate((timestamp - create_time));
  42. currentTimeHtml = currentTime[0] + ' 年 ' + currentTime[1] + ' 天 ' + currentTime[2] + ' 时 ' + currentTime[3] + ' 分 ' + currentTime[4] + ' 秒';
  43. document.getElementById("htmer_time").innerHTML = currentTimeHtml;
  44. }
  45. setInterval(setTime, 1000);
  46. </script>
  47. </div>