Generate seconds using Datetime.UTCNow C# [duplicate]
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
This question already has an answer here:
How do you convert epoch time in C#?
10 answers
How can I convert a DateTime to the number of seconds since 1970?
6 answers
Can somebody please let me know how to get Timestamp as a string which is equal to the number of seconds since January 1, 1970 in UTC (Coordinated Universal Time)?
I tried below function from one of the post on stackoverflow but it's showing wrong timestamp error.
public long GetEpochTime()
{
DateTime dtCurTime = DateTime.UtcNow;
DateTime dtEpochStartTime = Convert.ToDateTime("1/1/1970 00:00:00");//also tried 1/1/1970 00:00:00
TimeSpan ts = dtCurTime.Subtract(dtEpochStartTime);
long epochtime;
epochtime = ((((((ts.Days * 24) + ts.Hours) * 60) + ts.Minutes) * 60) + ts.Seconds);
return epochtime;
}
I'm using this with Payment Gateway which throws an error for a wrong timestamp.
c# timestamp utc
marked as duplicate by Alberto Solano, dymanoid, Ehsan Sajjad
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 26 '18 at 14:17
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How do you convert epoch time in C#?
10 answers
How can I convert a DateTime to the number of seconds since 1970?
6 answers
Can somebody please let me know how to get Timestamp as a string which is equal to the number of seconds since January 1, 1970 in UTC (Coordinated Universal Time)?
I tried below function from one of the post on stackoverflow but it's showing wrong timestamp error.
public long GetEpochTime()
{
DateTime dtCurTime = DateTime.UtcNow;
DateTime dtEpochStartTime = Convert.ToDateTime("1/1/1970 00:00:00");//also tried 1/1/1970 00:00:00
TimeSpan ts = dtCurTime.Subtract(dtEpochStartTime);
long epochtime;
epochtime = ((((((ts.Days * 24) + ts.Hours) * 60) + ts.Minutes) * 60) + ts.Seconds);
return epochtime;
}
I'm using this with Payment Gateway which throws an error for a wrong timestamp.
c# timestamp utc
marked as duplicate by Alberto Solano, dymanoid, Ehsan Sajjad
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 26 '18 at 14:17
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Are you looking for ToUnixTimeSeconds?
– Corak
Nov 26 '18 at 14:04
add a comment |
This question already has an answer here:
How do you convert epoch time in C#?
10 answers
How can I convert a DateTime to the number of seconds since 1970?
6 answers
Can somebody please let me know how to get Timestamp as a string which is equal to the number of seconds since January 1, 1970 in UTC (Coordinated Universal Time)?
I tried below function from one of the post on stackoverflow but it's showing wrong timestamp error.
public long GetEpochTime()
{
DateTime dtCurTime = DateTime.UtcNow;
DateTime dtEpochStartTime = Convert.ToDateTime("1/1/1970 00:00:00");//also tried 1/1/1970 00:00:00
TimeSpan ts = dtCurTime.Subtract(dtEpochStartTime);
long epochtime;
epochtime = ((((((ts.Days * 24) + ts.Hours) * 60) + ts.Minutes) * 60) + ts.Seconds);
return epochtime;
}
I'm using this with Payment Gateway which throws an error for a wrong timestamp.
c# timestamp utc
This question already has an answer here:
How do you convert epoch time in C#?
10 answers
How can I convert a DateTime to the number of seconds since 1970?
6 answers
Can somebody please let me know how to get Timestamp as a string which is equal to the number of seconds since January 1, 1970 in UTC (Coordinated Universal Time)?
I tried below function from one of the post on stackoverflow but it's showing wrong timestamp error.
public long GetEpochTime()
{
DateTime dtCurTime = DateTime.UtcNow;
DateTime dtEpochStartTime = Convert.ToDateTime("1/1/1970 00:00:00");//also tried 1/1/1970 00:00:00
TimeSpan ts = dtCurTime.Subtract(dtEpochStartTime);
long epochtime;
epochtime = ((((((ts.Days * 24) + ts.Hours) * 60) + ts.Minutes) * 60) + ts.Seconds);
return epochtime;
}
I'm using this with Payment Gateway which throws an error for a wrong timestamp.
This question already has an answer here:
How do you convert epoch time in C#?
10 answers
How can I convert a DateTime to the number of seconds since 1970?
6 answers
c# timestamp utc
c# timestamp utc
asked Nov 26 '18 at 13:58
Manish DhariwalManish Dhariwal
186
186
marked as duplicate by Alberto Solano, dymanoid, Ehsan Sajjad
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 26 '18 at 14:17
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Alberto Solano, dymanoid, Ehsan Sajjad
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 26 '18 at 14:17
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Are you looking for ToUnixTimeSeconds?
– Corak
Nov 26 '18 at 14:04
add a comment |
1
Are you looking for ToUnixTimeSeconds?
– Corak
Nov 26 '18 at 14:04
1
1
Are you looking for ToUnixTimeSeconds?
– Corak
Nov 26 '18 at 14:04
Are you looking for ToUnixTimeSeconds?
– Corak
Nov 26 '18 at 14:04
add a comment |
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
1
Are you looking for ToUnixTimeSeconds?
– Corak
Nov 26 '18 at 14:04