Question: I am getting a date string in this format - 'March 12 2019 11:30 pm' and also the offset in hours like +5.5. I want to convert this date into my browser timezone.

I have tried the following code

```
function convertToLocalTime(date, offset) {
  const serverTime = new Date(date);
  const localOffset = offset * 3600000;
  const d = new Date(serverTime.getTime() + localOffset).toUTCString();
  return new Date(d);
}

```

But I am getting the date as `Tue Mar 12 2019 15:30:00 GMT+0530 (India Standard Time)` which is wrong.

The expected result should be if the date is March 12 2019 11:30 pm and the offset given is -8 and my local time has an offset of +5.5, I should get the date as March 13 2019 12:00 pm.

`convertToLocalTime('March 12 2019 11:30 pm', -8)` 
should give the date as March 13 2019 12:00 pm.

Answer: 
You can specify which parts to scaffold. The following is an excerpt from the ASP.NET Core documentation. Link to the source below.

**To disable user registration:**

* Scaffold Identity. Include Account.Register, Account.Login, and Account.RegisterConfirmation. For example:

```
dotnet aspnet-codegenerator identity -dc RPauth.Data.ApplicationDbContext --files "Account.Register;Account.Login;Account.RegisterConfirmation"

```

* Update *Areas/Identity/Pages/Account/Register.cshtml.cs* so users can't register from this endpoint:

```
public class RegisterModel : PageModel
{
    public IActionResult OnGet()
    {
        return RedirectToPage("Login");
    }

    public IActionResult OnPost()
    {
        return RedirectToPage("Login");
    }
}

```

* Update *Areas/Identity/Pages/Account/Register.cshtml* to be consistent with the preceding changes:

```
@page
@model RegisterModel
@{
    ViewData["Title"] = "Go to Login";
}

<h1>@ViewData["Title"]</h1>

<li class="nav-item">
    <a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Login">Login</a>
</li>

```

* Comment out or remove the registration link from *Areas/Identity/Pages/Account/Login.cshtml*

```
@*
<p>
    <a asp-page="./Register" asp-route-returnUrl="@Model.ReturnUrl">Register as a new user</a>
</p>
*@

```

* Update the *Areas/Identity/Pages/Account/RegisterConfirmation* page.
	+ Remove the code and links from the cshtml file.
	+ Remove the confirmation code from the `PageModel`:

```
[AllowAnonymous]
public class RegisterConfirmationModel : PageModel
{
    public IActionResult OnGet()
    {  
        return Page();
    }
}

```

Source: <https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.2&tabs=visual-studio#disable-register-page>

More information about `dotnet aspnet-codegenerator`: <https://learn.microsoft.com/en-us/aspnet/core/fundamentals/tools/dotnet-aspnet-codegenerator>
For ASP.NET Core 3.1 and up you can scaffold the page from Visual Studio GUI. Instll NuGet `Microsoft.VisualStudio.Web.CodeGeneration.Design` and then do it like this:

* From Solution Explorer, right-click on the project > Add > New
Scaffolded Item.
* From the left pane of the Add New Scaffolded Item
dialog, select Identity > Add.
* In the Add Identity dialog, select the
options you want.
	+ Select your existing layout page, or your layout
	file will be overwritten with incorrect markup:
		- ~/Pages/Shared/\_Layout.cshtml for Razor Pages
		- ~/Views/Shared/\_Layout.cshtml for MVC projects
		- Blazor Server apps
		created from the Blazor Server template (blazorserver) aren't
		configured for Razor Pages or MVC by default. Leave the layout page
		entry blank.
	+ Select the + button to create a new Data context class.
	Accept the default value or specify a class (for example,
	MyApplication.Data.ApplicationDbContext).
* Select Add.

<https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-6.0&tabs=visual-studio#scaffold-identity-into-a-razor-project-with-authorization>

You can then follow the guide from MS/@Niels R.:

<https://stackoverflow.com/a/58852405/3850405>

<https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-6.0&tabs=visual-studio#disable-a-page>