Activity Forums Salesforce® Discussions Has anyone created a VF page which accepts value for a datetime field sepereately as date and time?

  • Has anyone created a VF page which accepts value for a datetime field sepereately as date and time?

    Posted by Deepak on October 11, 2019 at 12:59 pm

    Has anyone created a VF page which accepts value for a datetime field sepereately as date and time in salesforce?

    Laveena replied 5 years ago 2 Members · 1 Reply
  • 1 Reply
  • Laveena

    Member
    October 11, 2019 at 1:13 pm

    Hi Deepak,

    Date d=System.Today();
    String sDate = String.valueOf(d);
    string datime='13:00:00';
    string stringDate=sDate+' '+datime;
    System.debug('The concated String :'+stringDate);
    Datetime myDate = datetime.valueOf(stringDate);
    System.debug('The value of myDate'+myDate);

    Consider few points

    1)Dont hard code in select option .Use Custom setting for Same .This will give flexibilty for admin to add or modify later

    2)Even in Debug log you may see different time but yes no issues on that since it always shows in GMT and according to the local of the user value will be adjusted .

    3)You can use standard date field for the user to allow select the Date.

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos