i am trying to add two input fields , one output field and one button in lightning component and then upon adding this component to app builder , i am getting this error.

Code is as follows:


<aura:component controller="JN_TimeZoneIssue" implements="flexipage:availableForAllPageTypes" >

  <ui:inputText label="Enter the time " aura:id="name" value="{!v.dateAndTime}"/>
   <ui:inputText label="Enter the time zone " aura:id="name1" value="{!v.timeZone}" />
   <ui:outputText aura:id="nameOutput" value="{!v.outputTime}"/>
    <ui:button aura:id="outputButton" label="Convert Time" press="{!c.calculateTime}"/>


Component controller:

    getInput : function(component, event, helper) {
             //: function(cmp, event) {
      var selectedTime = component.find("name").get("v.value");
      var selectedTimeZone = component.find("name1").get("v.value");
     // var outName = cmp.find("nameOutput");        
      var action = component.get("c.calculateTime");
            "selectedTime": selectedTime
             "selectedTimeZone" :selectedTimeZone 

        action.setCallback(this, function(data) {
        component.set("v.outputTime", data.getReturnValue());



Apex COntroller:

public class JN_TimeZoneIssue {

   @AuraEnabled public String timeZone{get;set;}
   @AuraEnabled public Datetime dateAndTime{get;set;}
 //  @AuraEnabled public boolean showOutput{get;set;}
   @AuraEnabled public String updatedTime{get;set;}

    public static String calculateTime(String selectedTimeZone, Datetime selectedTime){
        String newTime =   selectedTime.format('MM/dd/yyyy hh:mm:ss a',+selectedTimeZone);
        return newTime;

  • I don't see an error. Could you please edit your question?
    – sfdcfox
    Commented Aug 9, 2017 at 19:24

1 Answer 1


Your component is missing a lot of information

1) None of the attributes are declared in your component.

2) Rewire you button to call getInput method missing in client side controller.

3) This is the actual reason why you are seeing the error"Cannot read property 'apply' of undefined" , you are missing a comma between the 2 parameters in your setparams:

            "selectedTime": selectedTime,
             "selectedTimeZone" :selectedTimeZone 


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .