phpstormlive-templates

Insert current time OR date in PhpStorm Live Template


How can I have a Live Template in PhpStorm that inserts the current time?

For example:

/**
 * @author Person
 * @time   27/07/2021    
 */

Solution

  • Sure, just use provided predefined date() and time() functions with desired format as a parameter:

    https://www.jetbrains.com/help/phpstorm/edit-template-variables-dialog.html#predefined_functions

    Live template text:

    /**
     * @author Person
     * @time   $DATE$ $TIME$    
     */
    

    Edit Variables (adjust the format as needed in an optional parameter (uses Java's SimpleDateFormat -- see the function description in the aforementioned link)):

    enter image description here

    An example result for the above template:

    /**
     * @author Person
     * @time   27/07/2021 15:39:01    
     */