Advertisement
pusatdata

Custom WP Get Date

Apr 15th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. ASLINYA
  2. <?php echo get_the_date(); ?>
  3.  
  4. BENTUK LAIN:
  5. <?php echo get_the_date('l d/m/Y'); ?>
  6.  
  7. <?php echo get_the_date('l, j F Y'); ?>
  8. Hasilnya: Minggu, 9 Januari 2017
  9.  
  10. <?php echo get_the_date('D, d M Y'); ?>
  11. Hasilnya: Min, 09 Jan 2017
  12.  
  13.  
  14.  
  15. For example, the format string:
  16.  
  17. l, F j, Y
  18. creates a date that look like this:
  19.  
  20. Friday, September 24, 2004
  21. Here is what each format character in the string above represents:
  22.  
  23. l = Full name for day of the week (lower-case L).
  24. F = Full name for the month.
  25. j = The day of the month.
  26. Y = The year in 4 digits. (lower-case y gives the year's last 2 digits)
  27. (Commas are read literally.)
  28. WordPress is written in the programming language PHP. The date formatting functions in WordPress use PHP's built-in date formatting functions. You can use the table of date format characters on the PHP website as a reference for building date format strings for use in WordPress. Here is a table of some of the more useful items found there:
  29.  
  30. Day of Month
  31. d Numeric, with leading zeros 01–31
  32. j Numeric, without leading zeros 1–31
  33. S The English suffix for the day of the month st, nd or th in the 1st, 2nd or 15th.
  34. Weekday
  35. l Full name (lowercase 'L') Sunday – Saturday
  36. D Three letter name Mon – Sun
  37. Month
  38. m Numeric, with leading zeros 01–12
  39. n Numeric, without leading zeros 1–12
  40. F Textual full January – December
  41. M Textual three letters Jan - Dec
  42. Year
  43. Y Numeric, 4 digits Eg., 1999, 2003
  44. y Numeric, 2 digits Eg., 99, 03
  45. Time
  46. a Lowercase am, pm
  47. A Uppercase AM, PM
  48. g Hour, 12-hour, without leading zeros 1–12
  49. h Hour, 12-hour, with leading zeros 01–12
  50. G Hour, 24-hour, without leading zeros 0-23
  51. H Hour, 24-hour, with leading zeros 00-23
  52. i Minutes, with leading zeros 00-59
  53. s Seconds, with leading zeros 00-59
  54. T Timezone abbreviation Eg., EST, MDT ...
  55. Full Date/Time
  56. c ISO 8601 2004-02-12T15:19:21+00:00
  57. r RFC 2822 Thu, 21 Dec 2000 16:01:07 +0200
  58. U Unix timestamp (seconds since Unix Epoch) 1455880176
  59. Examples
  60. Here are some examples of date format and result output.
  61.  
  62. F j, Y g:i a - November 6, 2010 12:50 am
  63. F j, Y - November 6, 2010
  64. F, Y - November, 2010
  65. g:i a - 12:50 am
  66. g:i:s a - 12:50:48 am
  67. l, F jS, Y - Saturday, November 6th, 2010
  68. M j, Y @ G:i - Nov 6, 2010 @ 0:50
  69. Y/m/d \a\t g:i A - 2010/11/06 at 12:50 AM
  70. Y/m/d \a\t g:ia - 2010/11/06 at 12:50am
  71. Y/m/d g:i:s A - 2010/11/06 12:50:48 AM
  72. Y/m/d - 2010/11/06
  73. Combined with the_time() template tag, the code below in the template file:
  74.  
  75. This entry was posted on <?php the_time('l, F jS, Y') ?> and is filed under <?php the_category(', ') ?>.
  76. will be shown on your site as following:
  77.  
  78. This entry was posted on Friday, September 24th, 2004 and is filed under WordPress and WordPress Tips.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement