How to display System time in SystemVerilog

module test;
  
  function string get_time();
    int    file_pointer;
    
    //Stores time and date to file sys_time
    void'($system("date +%X--%x > sys_time"));
    //Open the file sys_time with read access
    file_pointer = $fopen("sys_time","r");
    //assin the value from file to variable
    void'($fscanf(file_pointer,"%s",get_time));
    //close the file
    $fclose(file_pointer);
    void'($system("rm sys_time"));
  endfunction
  
  initial begin
    $display("Current System Time is %s",get_time());
  end
endmodule

Simulator Output

Current System Time is 14:39:06--04/25/17

Click to execute on