我有一个以毫秒为单位的时间,即 1274203800000,现在我想在 javascript 中将其转换为 GMT + 10。
目前我正在使用以下代码来做到这一点
var milliseconds=1274203800000;
var offset='+10';
var d = new Date(milliseconds);
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
nd = new Date(utc + (3600000*offset));
var result=nd.toLocaleString();
alert(result);
Run Code Online (Sandbox Code Playgroud)
上面的代码评估为“2010 年 5 月 19 日星期三 3:30:00 AM”日期,但这不是“2010 年 5 月 18 日星期二 3:30:00这种情况)是正确的。但我不知道这里有什么问题。
我当前的本地时区是 GMT+0530。
我现在已经盯着自己,所以请帮忙.
当我在循环内调用此方法两次时,它返回相同的值.为什么?
public async Task<int> RollDice() {
var rnd = new Random();
var selected = 0;
await Task.Run(() => {
selected = rnd.Next(1, 6);
});
return selected;
}
Run Code Online (Sandbox Code Playgroud) 我想传递URL,我的代码是:
MyUrl = "http://www.abc.co.in/Download.aspx?period=" + Server.UrlEncode
(DateTime.Now.ToString("dd-MMM-yyyy")) + "&ProductName="
+ Server.UrlEncode(productName) + "";
mail.Body += "<a href=" + MyUrl + ">Demo Download</a>";
Run Code Online (Sandbox Code Playgroud)
但我仍然得到如下输出:
http://www.abc.co.in/Download.aspx?period=12-Apr-2013&ProductName=Otja
那么我的代码有什么问题以及如何解码呢download.aspx?
我使用下面的查询,但它显示了一些重复的项目。所以我使用了该group功能,但它不起作用。
SELECT p.productId, p.productName, p.catId, p.subCatId, p.productType,
p.modelNo, p.picUrl, p.color, p.theme, p.productPrice, p.discountedPrice,
p.quantity, p.details, p.mainPageDisplay, p.productPageDisplay,
s.subCatId AS Expr1,
s.subCatName, s.catId AS Expr2,
s.rank, s.subCatName AS Expr3
FROM (products p INNER JOIN
subCategories s ON p.catId = s.catId)
WHERE (p.color = 'red') group By p.productName
Run Code Online (Sandbox Code Playgroud)
这个查询工作正常,但是当我添加group by时它不起作用。
我正在尝试按如下方式创建这样的自定义类.
public MyClass<T>
{
public string Value1 { get; set; }
public T Value2 { get; set; }
public string Value3 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
T的值可以是字符串或int或datetime.我假设我可以创建此类的新实例
MyClass<int> intclass = new MyClass<int>();
MyClass<String> stringclass=new MyClass<String>();
Run Code Online (Sandbox Code Playgroud)
等等.
是否可以创建上述类的集合,我可以将intclass和stringclass放入自定义集合中.
我编写了以下代码将 XLSX 文件转换为 CSV 格式:
If WScript.Arguments.Count < 2 Then
WScript.Echo "Error! Please specify the source path and the destination. Usage: XlsToCsv SourcePath.xls Destination.csv"
Wscript.Quit
End If
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
oBook.SaveAs WScript.Arguments.Item(1), 6
oBook.Close False
oExcel.Quit
Run Code Online (Sandbox Code Playgroud)
当我为 XLSX 文件提供服务器路径时,它工作正常。但是,当我提供本地计算机路径时,它给出以下错误:
找不到文件。检查文件名的拼写,并验证文件位置是否正确。如果您尝试从最近使用的文件列表中打开该文件,请确保该文件未被重命名、移动或删除
代码:800A03EC
来源:Microsoft Office Excel
我试图让我的头脑绕多线程.
对于简单的任务,我发现最简单的方法是这样做:
new Thread(delegate()
{
Console.Writeline("doing stuff here");
}).Start();
new Thread(delegate()
{
Console.Writeline("doing other stuff here");
}).Start();
Run Code Online (Sandbox Code Playgroud)
我想知道的是,如果我在我的两个线程中调用一个方法,这会导致冲突:
new Thread(delegate()
{
dostuff();
}).Start();
new Thread(delegate()
{
dostuff();
}).Start();
private void dostuff()
{
Console.WriteLine("Do Stuff Here");
}
Run Code Online (Sandbox Code Playgroud) 我有一个字典,我放在会话中,在每个按钮点击我需要执行一些操作.
itemColl = new Dictionary<int, int>();
Run Code Online (Sandbox Code Playgroud)
我想搜索一个我在会话变量中维护的密钥,如果密钥存在,那么我想将相应密钥的值增加1,我该如何实现.
我正在尝试如下:
if (Session["CurrCatId"] != null)
{
CurrCatId = (int)(Session["CurrCatId"]);
// this is the first time, next time i will fetch from session
// and want to search the currcatid and increase the value from
// corresponding key by 1.
itemColl = new Dictionary<int, int>();
itemColl.Add(CurrCatId, 1);
Session["itemColl"] = itemColl;
}
Run Code Online (Sandbox Code Playgroud) 我有一套枚举
public enum enums
{
enum1,
enum2,
enum3,
enum4,
enum5
}
Run Code Online (Sandbox Code Playgroud)
在另一个类中我想要两个对象:
var object1 = new enums();//Here I want an enum of enum1,enum2
var object2 = new enums();//Here I want an enum of enum3,enum4,enum5
Run Code Online (Sandbox Code Playgroud)
是否有人知道如何做到这一点?
我有一个我写过的C#应用程序,但我的Convert.ToDateTime工作时间过去了09:59?
这是我的代码:
strDateTime = Convert.ToDateTime(arr[3].TrimStart('[').Substring(0, 11) + " " + arr[3].TrimStart('[').Substring(13, 7));
Run Code Online (Sandbox Code Playgroud)
这就是arr[3]:
[20/Feb/2014:14:21:32 +0100]
这让我疯狂!
谢谢
c# ×7
asp.net ×2
async-await ×1
collections ×1
datetime ×1
enums ×1
generics ×1
group-by ×1
javascript ×1
random ×1
sql ×1
sql-server ×1
timezone ×1
vbscript ×1