从日期开始获取当天的名称

时间:2017-10-10 12:21:06

标签: powershell date batch-file cmd weekday

我想显示给定日期的日期名称。我有一个代码,可以在系统日期之前给我起名字。

@model FileCurdoperation.Models.PersonModel

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

@using (Html.BeginForm("Index", "Employee", FormMethod.Post, new { enctype = "multipart/form-data", name = "blogform", id = "blogform" }))
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>PersonModel</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.email, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.email, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.email, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => model.Photo, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @*@Html.TextBoxFor(model => model.Photo, new { type = "file",@class = "form-control" })*@
                <input type="file" id="Photo" name="Photo" />
                @Html.ValidationMessageFor(model => model.Photo, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="button" value="Create" onclick="UpdateDetails();" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
<script>
    function UpdateDetails() {
        debugger;
        var image = $('#Photo').get('0').files[0];
        var param = { "Name": $('#Name').val().trim(), "email": $('#email').val().trim(), "Photo": $('#Photo').get('0').files[0] };
         param = JSON.stringify(param);
        $.ajax({
            type: "Post",
            url: "/Employee/Index",
            contentType: "application/json; charset=utf-8",
            data: param,
            dataType: "json",
            success: function (data) {
            },
            error: function (response) {
            }
        });
    };
</script>

我如何能够显示我将放入的任何日期的日期名称? 我想做这样的事情(我已经设置了日,月和年前的变量):

@for /F "tokens=1 delims=, " %%i In ('powershell date') do set dow=%%i
echo %dow%

1 个答案:

答案 0 :(得分:0)

改编自https://technet.microsoft.com/en-us/library/ff730960.aspx

for /f "delims=" %%d in ('powershell (get-date  %day%/%month%/%year%^).dayofweek') do set dow=%%d

出于测试目的:

@echo off
:...
echo Command line: powershell (get-date  %day%/%month%/%year%).dayofweek
echo Result:
powershell (get-date  %day%/%month%/%year%).dayofweek
for /f "delims=" %%d in ('powershell (get-date  %day%/%month%/%year%^).dayofweek') do set dow=%%d
echo dow=%dow%