Created
August 24, 2017 14:12
-
-
Save suresh-kumara-gist/04d866626fd464c15e08e44d45edaa35 to your computer and use it in GitHub Desktop.
drupal 8 way of creating timestamp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use Drupal\Component\Datetime\DateTimePlus; | |
| $format = "D"; | |
| // create current datetime. | |
| $current_date = new DateTimePlus(); | |
| // Format $current_date to dispaly, what ever php datetime format you needed. here I am formatting to 'D' | |
| $current_day = $current_date->format($format, ['timezone' => drupal_get_user_timezone()]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment