• 8

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I'm trying to get the current date/time add a number of days and display in a UTC format.

Current output is like this: 2019-05-09T11:11:4226

See code for below, I think I'm maybe taking the wrong approach to this.

       int NumDaysInFurure = 1;

        Date currentDate = new Date();// get the current date

        SimpleDateFormat daateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
        String date = ""+dateFormat.format(currentDate) + NumDaysInFurure;//add one day to the current date

        Log.i("the future date is", date);

Starting from Java8, this would be a better approach:

DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss").format(LocalDateTime.now().plusDays(1))

to break it down:


returns an instance of LocalDateTime with the current date and time. You add one day (using the plusDays(Long days)) method.

The result of this, you format using a DateTimeFromatter. The result of the complete is a String with the right date/format.

  • 1
Reply Report