Showing posts with label Salesforce. Show all posts
Showing posts with label Salesforce. Show all posts

24 May 2023

How to show the current time and date in Lightning Web Components (LWC) in Salesforce

use JavaScript's Date object and the LWC template syntax. Here's an example of how you can achieve this:

Open your LWC component's JavaScript file (e.g., myComponent.js) and define a property to store the current date and time.


import { LightningElement, track } from 'lwc';

export default class MyComponent extends LightningElement {

    @track currentDate;

    connectedCallback() {

        this.getCurrentDateTime();

    }

    getCurrentDateTime() {

        setInterval(() => {

            const now = new Date();

            this.currentDate = now.toLocaleString(); // Format the date and time as per your preference

        }, 1000); // Update every second

    }

}

Open your LWC component's HTML file (e.g., myComponent.html) and use the currentDate property to display the date and time.


<template>

    <div>{currentDate}</div>

</template>


 Now, when you use the MyComponent in your Lightning page, it will continuously update to display the current date and time.

Note: The example above sets the interval to update the date and time every second (1000 milliseconds). You can adjust the interval value to your desired frequency.

 

To display the current date and time in a specific format in Lightning Web Components (LWC) in Salesforce, you can use the toLocaleString method of the Date object and specify the desired format options. Here's an example:

import { LightningElement, track } from 'lwc';

export default class MyComponent extends LightningElement {

    @track currentDate;

    connectedCallback() {

        this.getCurrentDateTime();

    }

    getCurrentDateTime() {

        setInterval(() => {

            const now = new Date();

            const options = {

                year: 'numeric',

                month: 'long',

                day: 'numeric',

                hour: 'numeric',

                minute: 'numeric',

                second: 'numeric',

                hour12: true // Use 12-hour format (true) or 24-hour format (false)

            };

            this.currentDate = now.toLocaleString('en-US', options); // Adjust the locale as per your requirement

        }, 1000); // Update every second

    }

}


To display the current date and time in Indian date format using Lightning Web Components (LWC) in Salesforce, you can modify the options object in the toLocaleString method to match the desired format. Here's an example:

import { LightningElement, track } from 'lwc';

export default class MyComponent extends LightningElement {

    @track currentDate;

    connectedCallback() {

        this.getCurrentDateTime();

    }

    getCurrentDateTime() {

        setInterval(() => {

            const now = new Date();

            const options = {

                weekday: 'long',

                year: 'numeric',

                month: 'long',

                day: 'numeric',

                hour: 'numeric',

                minute: 'numeric',

                second: 'numeric',

                hour12: true, // Use 12-hour format (true) or 24-hour format (false)

                timeZone: 'Asia/Kolkata', // Set the desired time zone

                timeZoneName: 'short' // Show abbreviated time zone name

            };

            this.currentDate = now.toLocaleString('en-IN', options); // Use 'en-IN' locale for Indian date format

        }, 1000); // Update every second

    }

}

 

13 Mar 2023

Salesforce - Certification Path 2023

 Salesforce offers a variety of certifications that validate expertise in various aspects of their platform. Here is a list of Salesforce certifications:

  1. Salesforce Certified Administrator
  2. Salesforce Certified Advanced Administrator
  3. Salesforce Certified Sales Cloud Consultant
  4. Salesforce Certified Service Cloud Consultant
  5. Salesforce Certified Community Cloud Consultant
  6. Salesforce Certified Platform App Builder
  7. Salesforce Certified Platform Developer I
  8. Salesforce Certified Platform Developer II
  9. Salesforce Certified Marketing Cloud Email Specialist
  10. Salesforce Certified Marketing Cloud Administrator
  11. Salesforce Certified Marketing Cloud Consultant
  12. Salesforce Certified Pardot Specialist
  13. Salesforce Certified Pardot Consultant
  14. Salesforce Certified Field Service Lightning Consultant
  15. Salesforce Certified CPQ Specialist
  16. Salesforce Certified JavaScript Developer I
  17. Salesforce Certified Heroku Architecture Designer
  18. Salesforce Certified Integration Architecture Designer
  19. Salesforce Certified Sharing and Visibility Designer
  20. Salesforce Certified Data Architecture and Management Designer
  21. Salesforce Certified Identity and Access Management Designer
  22. Salesforce Certified Mobile Solutions Architecture Designer
  23. Salesforce Certified Technical Architect
  24. Salesforce Certified B2B Solution Architect
  25. Salesforce Certified B2C Solution Architect


Note: This list may not be exhaustive as Salesforce frequently updates and adds new certifications.


Salesforce Certification Path 2023