How to convert date to iso format in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! This tutorial will help you to convert date to iso format in typescript, here we will use the toISOString() method to convert date to iso format. what is toISOString()? The toISOString() method returns a string in simplified extended ISO format (ISO 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ or ±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always zero UTC offset, as denoted by the suffix “Z”....

May 1, 2022 · 1 min · Infinitbility

How to add items to array in javascript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ This tutorial will help you to add new items or elements to your array, here we will use the push() method to insert the new element in the array. JavaScript provides the push() method to add new elements an existing array, we have to just pass elements in the push() method. The push() method adds new elements at the last index of the array....

April 30, 2022 · 1 min · Infinitbility

How to convert date to timestamp in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert a date to the timestamp in typescript?, here we will use the date built-in method Date.parse() method to convert the date to timestamp format. So, let’s see what is Date.parse() method is? The Date.parse() method parses a string representation of a date and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC or NaN if the string is unrecognized or, in some cases, contains illegal date values (e....

April 29, 2022 · 1 min · Infinitbility

How to convert date to mm/dd/yyyy in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert date to mm/dd/yyyy in typescript?, here we will use custom method formatDate() method to convert date to mm/dd/yyyy format. So, first we have to create a function which get date as a parameter and return formated like we want… Here, we want format date as month/date/year like. let’s dive in code… const formatDate = (date: Date) => { function pad(s) { return (s < 10) ?...

April 27, 2022 · 1 min · Infinitbility

How to convert date to number in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert date to number in typescript?, here we will use date built-in method Date.parse() method to convert date to number format. So, let’s see what is Date.parse() method? The Date.parse() method parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC or NaN if the string is unrecognized or, in some cases, contains illegal date values (e....

April 27, 2022 · 1 min · Infinitbility

How to convert date to epoch time in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert date to epoch time in typescript, here we will use built-in method Date.parse() method to convert date to epoch time. First of all, let understand what is a epoch time? The Unix epoch or Unix time is the number of seconds elapsed since January 1, 1970. The getTime() method is used to return the millisecond representation of the Date object....

April 26, 2022 · 1 min · Infinitbility

How to convert date to string format in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert date to date string format in typescript, here we will use built-in method .toString() to convert date to string date. First, we will create sample new date() object variable, after then, we will use .toString() method to convert it on string date format. let’s dive in code… let date = new Date(); console.log(date); // 2022-04-25T08:21:19....

April 25, 2022 · 1 min · Infinitbility

How to convert date to utc format in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert date to utc format in typescript, here we will use built-in method .toUTCString() to convert date to utc date. First, we will create sample new date() object variable, after then, we will use .toUTCString() method to convert it on utc date format. let’s dive in code… let date = new Date(); console.log(date); // 2022-04-24T11:26:53.690Z let utcDate: string = date....

April 24, 2022 · 1 min · Infinitbility

How to convert string to char array in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert string to char array in typescript, here we will use built-in method .split() to convert string to array. Well, we have sample an string which we have to seprate and we have to pick those data and use as array. To do this things, we have built-in method .split() which we have to provide empty string seprator for to seprate every string char element....

April 23, 2022 · 1 min · Infinitbility

How to convert string to title case in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn how to convert string in any case like camel case, paskal case to title case in typescript, here we will create toTitleCase() custom method to convert string any case to title case. Well, let’s create a function which return the provided string with the first letter of each word capitalized and Make sure the rest of the word is in lower case....

April 22, 2022 · 1 min · Infinitbility

How to convert comma separated string to array in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn how to convert comma (,) separated string to array in typescript, here we will use built-in method .split() to convert string to array. Well, we have an string which have comma ( , ) seprate data and we have to pick those data and use as array. To do this things, we have built-in method .split() which we have to provide seprator for now it’s comma and it will return an array....

April 20, 2022 · 1 min · Infinitbility

How to convert a string to uppercase in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how to convert a string to uppercase in typescript, here we will use the javascript toUpperCase() method to convert it an uppercase. So first, we will create some examples variables, then we use the toUpperCase() method on those variables, and then we will check our console it’s working or not. Let’s start codeing… let firstStr: string = 'Hello World'; let secondStr: string = 'Infinitbility'; let thirdStr: string = 'IfergUokgIgokr04'; // lets convert it firstStr = firstStr....

April 17, 2022 · 1 min · Infinitbility

How to convert a string to lowercase in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how to convert string to lowercase in typescript, here we will use the javascript toLowerCase() method to convert to lowercase. So first, we will create some examples variables, then we use the toLowerCase() method on those variables, and then we will check our console it’s working or not. Let’s start coding… let firstStr: string = 'Hello World'; let secondStr: string = 'Infinitbility'; let thirdStr: string = 'IfergUokgIgokr04'; // lets convert it firstStr = firstStr....

April 16, 2022 · 1 min · Infinitbility

How to convert any to string in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! This tutorial will help you to convert any type of data to a string in typescript, here we will use the built-in method .toString() method to convert data any type to a string. we will first create any type variable with sample array data and then we will check their data type. after that we will use the .toString() method to convert it into a string....

April 14, 2022 · 1 min · Infinitbility

How to convert object to json string in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to see how we can convert the object to JSON string in typescript, here we will use the built-in method JSON.stringify() to convert data object to JSON string. When you want to pass data to API or anywhere then you should stringify your JSON. Here, we will create a sample object and then we use JSON.stringify() to convert the object to a string....

April 14, 2022 · 1 min · Infinitbility

How to convert string to json in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to see how we can convert string to object in typescript, here we will use the built-in method JSON.parse() to convert data string to JSON. When you get a string from any API or anywhere and it looks like JSON key-value pair for example '{"id":1,"name":"infinitbility","domain":"infinitbility.com","age":2,"isActive":1}' and you won’t use it then first you to parse it. let’s start code....

April 14, 2022 · 1 min · Infinitbility

How to convert string to boolean in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to see how we can convert string to boolean in typescript, here we are going to use the ternary operator to convert string to boolean. To convert a string to a boolean, we have to check whether 'true' is present in the string or not, and if present we have to assign a new true value or false. In the following code, we are taken of both cases if the string true or if string false....

April 13, 2022 · 1 min · Infinitbility

How to convert a string to camel case in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how can we convert normal string text to camel case in typescript, If you are using lodash then you have to just use their available camel case convert method. _.camelCase('Foo Bar'); // → 'fooBar' _.camelCase('--foo-bar--'); // → 'fooBar' _.camelCase('__FOO_BAR__'); // → 'fooBar but in this article, we are going to create a custom function that converts text to camelCase text....

April 11, 2022 · 2 min · Infinitbility

How to convert object keys to array in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how to convert object keys to array in typescript, here we use some javascript Objects method like Object.keys() method. Sometime’s we need to create array from object keys and that’s why we simple method Object.keys() interface User { id: number; name: string; domain?: string; age?: number; isActive?: boolean; } let user: User = { id: 1, name: "infinitbility", domain: "infinitbility....

April 9, 2022 · 1 min · Infinitbility

How to convert object values to array in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how to convert object values to array in typescript, here we use some javascript Objects method like Object.values() method. Sometime’s we need to create array from object values and that’s why we simple method Object.values() interface User { id: number; name: string; domain?: string; age?: number; isActive?: boolean; } let user: User = { id: 1, name: "infinitbility", domain: "infinitbility....

April 9, 2022 · 1 min · Infinitbility