function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ravi Dutt SharmaRavi Dutt Sharma 

How to save lightning:input type="datetime-local" to database?

It seems that there is a bug with lightning:input type="datetime-local" tag. When I add this tag in my component, thenchoose a date and time using the date time selector and try to save the record to database, apex is not able to take the value? Any pointers on how to save this value to a date time field present on an object. Below is the sample code I am trying to implement:

<aura:component controller="DateTimeLocalCtrl">
    <aura:attribute name="lead" type="Lead" default="{'sobjectType':'Lead','id':'00Q9000001BtwNE'}"/>
	<lightning:input type="datetime-local" label="Start" name="Start" value="{!v.lead.Start__c}"/>
    <lightning:button label="Save" iconName="utility:save" onclick="{!c.doSave}"/>
	doSave : function(component, event, helper) {
       var action = component.get("c.upsertLead");
        var lead = component.get("v.lead");
        console.log("*****Date: "+component.get("v.lead.Start__c"));
        // set param to method  
            'ld': lead
        // set a callBack    
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
        // enqueue the Action  

public class DateTimeLocalCtrl {

    public static Lead upsertLead(Lead ld){
        upsert ld;
        return ld;

hi ravi, yes this is a issue with date time local lightning:input component type :
sara morgan provied a workaround for it please check below link :
i hope it helps you.
   Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others

Ravi Dutt SharmaRavi Dutt Sharma
Thanks, I already had a look at this link. Using the workaround mentioned in the link, it disturbs the time zone, so that workaround won't work. Regards, Ravi Dutt Sharma
opss then let me validate it in my dev org, and can you tell what value you enter in this field ?
Ravi Dutt SharmaRavi Dutt Sharma
Select any value in through the date time picker, it will give you an error when you hit the Save button