Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi am trying to figerout how to remove hours from and dateTime
Right now i get Hours from 2014-12-07 8:00 to 2014-12-09 to 17:00
And display them in an select option, how could i make so i only display
2014-12-07 from 8 to 17 and 2014-12-08 8 to 17 and 2014-12-09 8 to 17

Is it possible to take day buy day and only display time between 8-17

JavaScript
if (from.getHours() == "17") 


I have tried like something like this but when putting break; inside it only displays 8-17 on the 2014-12-07 and not the rest off the days.

Any Help Maybe? Is it possible maybe on someway to get date by date and and remove the hours that are between the night?
Posted
Comments
Sinisa Hajnal 8-Dec-14 2:35am    
You want to remove the entries completely or just remove hours and leave the dates? How are you generating the list?
Azziet 8-Dec-14 2:37am    
please share you complete code, not getting exact problem...
but you can use this to get only date

var d = new Date(year, month, day);

hi,
As I understand your problem,you want to split date from time.


Tyr this

var dateStr = "2014-12-07 08:00 , 2014-12-07 17:00";
var str_array = dateStr.split(' , ');

var FromDateTime As DateTime = DateTime.Parse(str_array[0])
var FromDate As String = FromDateTime.ToString("dd/MMM/yy")
var FromTime As String = FromDateTime.ToString("HH:mm")

var ToDateTime As DateTime = DateTime.Parse(str_array[1])
var ToDate As String = ToDateTime.ToString("dd/MMM/yy")
var ToTime As String = ToDateTime.ToString("HH:mm")


var fromDate = FromDate; // year month day
var fromTime= FromTime; // hours minutes
var toDate = ToDate; // yearsto monthto dayto
var toTime = ToTime; // hoursto hoursfrom
 
Share this answer
 
Try this

C#
DateTime time1 = Convert.ToDateTime(DateTime.Now.ToShortDateString());
string date = time1.ToString("dd-MM-yyyy");
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900