title: To store DateTime value into php and mysql
body: <p>I am working on how to put Date value into my PHP/MySQL using android's date picker. <br />
  I want to make a Sharing Parking lot application that owner can register one's parking place with its information like operating time. Then user can use it with choosing the beginning and ending points.<br />
  I searched a lot but need more specific information.<br />
  How can I save operating time slot into PHP/MySQL?</p>
  
  <p>The following is my android java code.</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.avtivity_date_time);
  
      mText1 = (TextView) findViewById(R.id.text1);
      mPickDate1 = (Button) findViewById(R.id.pickDate1);
      mPickTime1 = (Button) findViewById(R.id.pickTime1);
  
      mText2 = (TextView) findViewById(R.id.text2);
      mPickDate2 = (Button) findViewById(R.id.pickDate2);
      mPickTime2 = (Button) findViewById(R.id.pickTime2);
  
      mPickDate1.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              showDialog(DATE_DIALOG_ID_1);
          }
      });
  
      mPickDate2.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              showDialog(DATE_DIALOG_ID_2);
          }
      });
  
      mPickTime1.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              showDialog(TIME_DIALOG_ID_1);
          }
      });
  
      mPickTime2.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              showDialog(TIME_DIALOG_ID_2);
          }
      });
  
      final Calendar c = Calendar.getInstance();
      mYear1 = c.get(Calendar.YEAR);
      mMonth1 = c.get(Calendar.MONTH);
      mDay1 = c.get(Calendar.DAY_OF_MONTH);
      mHour1 = c.get(Calendar.HOUR_OF_DAY);
      mMinute1 = c.get(Calendar.MINUTE);
  
      mYear2 = c.get(Calendar.YEAR);
      mMonth2 = c.get(Calendar.MONTH);
      mDay2 = c.get(Calendar.DAY_OF_MONTH);
      mHour2 = c.get(Calendar.HOUR_OF_DAY);
      mMinute2 = c.get(Calendar.MINUTE);
  
      updateDisplay();
  }
  
  private void updateDisplay() {
      mText1.setText(String.format("시작 : %d년 %d월 %d일 %d시 %d분", mYear1, mMonth1 + 1, mDay1, mHour1, mMinute1));
      mText2.setText(String.format("종료 : %d년 %d월 %d일 %d시 %d분", mYear2, mMonth2 + 1, mDay2, mHour2, mMinute2));
  }
  
  private DatePickerDialog.OnDateSetListener mDateSetListener1 =
          new DatePickerDialog.OnDateSetListener() {
              @Override
              public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                  mYear1 = year;
                  mMonth1 = monthOfYear;
                  mDay1 = dayOfMonth;
                  updateDisplay();
              }
          };
  private DatePickerDialog.OnDateSetListener mDateSetListener2 =
          new DatePickerDialog.OnDateSetListener() {
              @Override
              public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                  mYear2 = year;
                  mMonth2 = monthOfYear;
                  mDay2 = dayOfMonth;
                  updateDisplay();
              }
          };
  
  private TimePickerDialog.OnTimeSetListener mTimeSetListener1 =
          new TimePickerDialog.OnTimeSetListener() {
              @Override
              public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                  mHour1 = hourOfDay;
                  mMinute1 = minute;
                  updateDisplay();
              }
          };
  
  private TimePickerDialog.OnTimeSetListener mTimeSetListener2 =
          new TimePickerDialog.OnTimeSetListener() {
              @Override
              public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                  mHour2 = hourOfDay;
                  mMinute2 = minute;
                  updateDisplay();
              }
          };
  
  @Override
  protected Dialog onCreateDialog(int id) {
      switch (id) {
          case DATE_DIALOG_ID_1:
              return new DatePickerDialog(this, mDateSetListener1, mYear1, mMonth1, mDay1);
  
          case TIME_DIALOG_ID_1:
              return new TimePickerDialog(this, mTimeSetListener1, mHour1, mMinute1, false);
  
          case DATE_DIALOG_ID_2:
              return new DatePickerDialog(this, mDateSetListener2, mYear2, mMonth2, mDay2);
  
          case TIME_DIALOG_ID_2:
              return new TimePickerDialog(this, mTimeSetListener2, mHour2, mMinute2, false);
      }
      return null;
  }
  
  
  private Long getDateInMS(String stringDateTime) throws ParseException {
  
      SimpleDateFormat simpledateformat1 = new SimpleDateFormat("yyyy MM dd hh mm");
      SimpleDateFormat simpledateformat2 = new SimpleDateFormat("yyyy MM dd hh mm");
  
      String formatdate1 = simpledateformat1.format("mYear1, mMonth1, mDay1, mHour1, mMinute1");
      String formatdate2 = simpledateformat2.format("mYear12, mMonth2, mDay2, mHour2, mMinute2");
  
      Date startdate = simpledateformat1.parse(formatdate1);
      Date enddate = simpledateformat2.parse(formatdate2);
      return null;
  }
  </code></pre>